瀏覽代碼

给首页、商品详情页添加右上角分享功能

wangxin 6 年之前
父節點
當前提交
754af28dd6
共有 6 個文件被更改,包括 55 次插入17 次删除
  1. 1 1
      app.js
  2. 1 7
      template/carts/index.js
  3. 1 0
      template/cash/index.js
  4. 19 1
      template/home/index.js
  5. 8 8
      template/poster/index.js
  6. 25 0
      template/view/index.js

+ 1 - 1
app.js

@@ -21,7 +21,7 @@ App({
   /**
    * 判断是否登录状态
    */
-  isLogin: function (fun){
+  isLogin: function (){
     return dever.getSign() == '' ? false : true;
   },
 

+ 1 - 7
template/carts/index.js

@@ -64,7 +64,6 @@ Page({
     var list = this.data.list;
     for(var i=0; i<list.length; i++){
       if (list[i].product_id == id){
-        //list[i].num = list[i].num-1<=0?1:list[i].num-1;
         if(list[i].num-1 <= 0){
           list[i].num = 1;
           this.delOrder(null, id);
@@ -99,6 +98,7 @@ Page({
   doSettlement: function(){
     var list = this.data.list;
     var count=0;
+    this.product_ids = '';
     for(var i=0; i<list.length; i++){
       var product_id = list[i].product_id;
       var pay_price = list[i].product.pay_price;
@@ -135,12 +135,6 @@ Page({
       success:function(data, res){
         var pay = data.pay;
         console.log('requestPayment-1', pay);
-        console.log('requestPayment-2', {
-          timeStamp: pay.time,
-          nonceStr: pay.nonce_str,
-          package: 'prepay_id='+ pay.prepay_id,
-          signType: pay.sign_type,
-          paySign: pay.sign});
         wx.requestPayment({
           timeStamp: pay.time,
           nonceStr: pay.nonce_str,

+ 1 - 0
template/cash/index.js

@@ -32,6 +32,7 @@ Page({
   doSettlement: function(){
     var list = this.data.list;
     var count=0;
+    this.product_ids = '';
     for(var i=0; i<list.length; i++){
       var product_id = list[i].id;
       var pay_price = list[i].pay_price;

+ 19 - 1
template/home/index.js

@@ -16,7 +16,8 @@ Page({
       this.pid = arr[1];
       app.saveInviteUid(uid);
     }
-    if (app.isLogin){
+    
+    if (app.isLogin()){
       this.getHomeData(this);
     }else{
       var that = this;
@@ -126,4 +127,21 @@ Page({
   onReachBottom: function () {
     app.startPullDown(this);
   },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function (options) {
+    //打开好友列表
+    wx.showShareMenu({
+      withShareTicket: true,
+      success: function (res) {
+        console.log('wx.showShareMenu success', res.data);
+      },
+      fail: function (res) {
+        console.log('wx.showShareMenu fail', res.data);
+      }
+    })
+  }
+
 })

+ 8 - 8
template/poster/index.js

@@ -47,14 +47,14 @@ Page({
       }
     });
 
-    //拼接分享参数
-    var scene = app.getUid()+','+ this.pid;
-
-    return {
-      title: '',
-      desc: '',
-      path: '/template/home/index?scene=' + encodeURIComponent(scene)
-    };
+    if (app.getUid() != '') {//拼接分享参数
+      var scene = app.getUid() + ',' + this.pid;
+      return {
+        title: '',
+        desc: '',
+        path: '/template/home/index?scene=' + encodeURIComponent(scene)
+      };
+    }
 
   }
 })

+ 25 - 0
template/view/index.js

@@ -41,6 +41,31 @@ Page({
     } else {
       app.location('login/index');
     }
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function (options) {
+    //打开好友列表
+    wx.showShareMenu({
+      withShareTicket: true,
+      success: function (res) {
+        console.log('wx.showShareMenu success', res.data);
+      },
+      fail: function (res) {
+        console.log('wx.showShareMenu fail', res.data);
+      }
+    });
+
+    if (app.getUid() != '') {//拼接分享参数
+      var scene = app.getUid() + ',' + this.pid;
+      return {
+        title: '',
+        desc: '',
+        path: '/template/home/index?scene=' + encodeURIComponent(scene)
+      };
+    }
   }
 
 })