junyuanz лет назад: 5
Родитель
Сommit
5c2421e28e
1 измененных файлов с 88 добавлено и 31 удалено
  1. 88 31
      pages/projects/project-detail/project-detail.js

+ 88 - 31
pages/projects/project-detail/project-detail.js

@@ -45,7 +45,8 @@ Page({
     sname:'',
     canpay:true,
     checkbox:'',
-    noproduct:false
+    noproduct:false,
+    check:{}
   },
   onLoad: function (options) {
     this.data.productId = options.id;
@@ -74,6 +75,7 @@ Page({
     var params = {
     }
     var success = function (res) {
+    	that.setData({check:res.data})
       if (res.data.user_id > 0) {
         that.setData({
           bindTel: true
@@ -151,7 +153,7 @@ Page({
         clock: val.data.seckill_end
       });
       WxParse.wxParse('parse', 'html', p, that, 10)
-      that.projectImageLoading()
+
       if (val.data.seckill_state == 'seckill') {
         that.starttime()
       }
@@ -496,18 +498,60 @@ Page({
           }
         },
         fail: function (res) {
-          that.qcodeError = true
-          if (that.data.posterPopup) {
-            that.setData({
-              posterPopup: false
-            })
-            wx.showToast({
-              title: '海报生成失败,请稍后重试',
-              icon: 'none',
-              duration: 2000
-            })
-            wx.hideLoading()
-          }
+        	var url = 'v1/update/poster/' + this.data.productId
+			    var params = {
+			      type: 'project'
+			    }
+			    var success = function (res) {
+			      wx.getImageInfo({
+			        src: res.data.qrcode_url,
+			        success: function (res) {
+			          that.posterImage.qcode = res
+			          that.posterLoading++
+			          if (that.posterLoading === 4) {
+			            that.createCtx()
+			          }
+			        },
+			        fail: function (res) {
+			          that.qcodeError = true
+			          if (that.data.posterPopup) {
+			            that.setData({
+			              posterPopup: false
+			            })
+			            wx.showToast({
+			              title: '海报生成失败,请稍后重试',
+			              icon: 'none',
+			              duration: 2000
+			            })
+			            wx.hideLoading()
+			          }
+			        }
+			      })
+			      wx.getImageInfo({
+			        src: res.data.wx_head,
+			        success: function (res) {
+			          that.posterImage.head = res
+			          that.posterLoading++
+			          if (that.posterLoading === 4) {
+			            that.createCtx()
+			          }
+			        }
+			      })
+			    }
+			    _request.$put(url, params, success)
+        	
+//        that.qcodeError = true
+//        if (that.data.posterPopup) {
+//          that.setData({
+//            posterPopup: false
+//          })
+//          wx.showToast({
+//            title: '海报生成失败,请稍后重试',
+//            icon: 'none',
+//            duration: 2000
+//          })
+//          wx.hideLoading()
+//        }
         }
       })
       wx.getImageInfo({
@@ -524,23 +568,36 @@ Page({
     _request.$get(url, params, success)
   },
   createPoster () {
-    if (!this.qcodeError) {
-      if (!this.canvasLoading) {
-        wx.showLoading({
-          mask: true,
-          title: ''
-        })
-      }
-      this.setData({
-        posterPopup: true
-      })
-    } else {
-      wx.showToast({
-        title: '海报生成失败,请稍后重试',
-        icon: 'none',
-        duration: 2000
-      })
-    }
+  	let that = this;
+  	if(this.data.check && this.data.check.wx_user_id && this.data.check.wx_user_id > 0 && this.data.check.user_id > 0){
+  		that.projectImageLoading()
+  	
+  	
+	    if (!this.qcodeError) {
+	      if (!this.canvasLoading) {
+	        wx.showLoading({
+	          mask: true,
+	          title: ''
+	        })
+	      }
+	      this.setData({
+	        posterPopup: true
+	      })
+	    } else {
+	      wx.showToast({
+	        title: '海报生成失败,请稍后重试',
+	        icon: 'none',
+	        duration: 2000
+	      })
+	    }
+  	}else{
+  		wx.showToast({
+	        title: '请先完成授权登录',
+	        icon: 'none',
+	        duration: 2000
+	      })
+  	}
+    
   },
   posterClose () {
     this.setData({