wangxin 6 years ago
parent
commit
e8a9d02ed3
3 changed files with 14 additions and 14 deletions
  1. 12 0
      template/home/index.js
  2. 1 1
      template/poster/index.js
  3. 1 13
      template/view/index.js

+ 12 - 0
template/home/index.js

@@ -2,11 +2,20 @@ const app = getApp();
 
 Page({
   cashdialog: null,
+  pid: '',
   pg: 1,
   data: {
     isShowNull: false
   },
   onLoad: function (options) {
+    //产品详情路径附带参数,用于来源分享的参数scene=encodeURIComponent(uid, product_id)
+    if (options != null && typeof options.scene != 'undefined') {
+      let str = decodeURIComponent(options.scene);
+      let arr = str.split(',');
+      let uid = arr[0];
+      this.pid = arr[1];
+      app.saveInviteUid(uid);
+    }
     if (app.isLogin){
       this.getHomeData(this);
     }else{
@@ -31,6 +40,9 @@ Page({
    * 获取首页数据
    */
   getHomeData: function(that){
+    if(that.pid != ''){
+      app.location('view/index?id=' + that.pid);
+    }
     if (that.pg == 1) {
       app.showLoading();
     }

+ 1 - 1
template/poster/index.js

@@ -53,7 +53,7 @@ Page({
     return {
       title: '',
       desc: '',
-      path: '/template/view/index?scene=' + encodeURIComponent(scene)
+      path: '/template/home/index?scene=' + encodeURIComponent(scene)
     };
 
   }

+ 1 - 13
template/view/index.js

@@ -1,21 +1,9 @@
 const app = getApp();
 
 Page({
-  options: {},
   pid: '',
   onLoad: function (options) {
-    this.options = options;
-    //产品详情路径附带参数,用于来源分享的参数scene = uid, product_id
-    if (typeof options.scene == 'undefined') {//来源首页商品浏览
-      this.pid = options.id;
-    } else {//来源于分享
-      //海报分享,路径附带的参数 encodeURIComponent(uid, product_id)
-      let str = decodeURIComponent(options.scene);
-      let arr = str.split(',');
-      let uid = arr[0];
-      this.pid = arr[1];
-      app.saveInviteUid(uid);
-    }
+    this.pid = options.id;
     var that = this;
     app.showLoading();
     app.request('product.api.view', {id: this.pid}, {