Selaa lähdekoodia

调整分享生成图片缺少头像问题

junyuanz 4 vuotta sitten
vanhempi
commit
943fd02c6b
2 muutettua tiedostoa jossa 111 lisäystä ja 86 poistoa
  1. 108 76
      pages/projects/project-detail/project-detail.js
  2. 3 10
      project.config.json

+ 108 - 76
pages/projects/project-detail/project-detail.js

@@ -508,6 +508,7 @@ Page({
     _request.$get(url, params, success)
   },
   projectImageLoading () {
+	  console.log('do projectImageLoading');
     var that = this
     wx.getImageInfo({
       src: 'https://cfohow.hiwavo.com/xcx/poster6.jpg',
@@ -536,82 +537,113 @@ Page({
       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) {
-        	var url = 'v1/update/poster/' + that.data.productId
-			    var params = {
-			      type: 'project'
-			    }
-			    var success = function (res2) {
-			      wx.getImageInfo({
-			        src: res2.data.qrcode_url,
-			        success: function (res2) {
-			          that.posterImage.qcode = res2
-			          that.posterLoading++
-			          if (that.posterLoading === 4) {
-			            that.createCtx()
-			          }
-			        },
-			        fail: function (res2) {
-			          that.qcodeError = true
-			          if (that.data.posterPopup) {
-			            that.setData({
-			              posterPopup: false
-			            })
-			            wx.showToast({
-			              title: '海报生成失败,请稍后重试',
-			              icon: 'none',
-			              duration: 2000
-			            })
-			            wx.hideLoading()
-			          }
-			        }
-			      })
-			      wx.getImageInfo({
-			        src: res2.data.wx_head,
-			        success: function (res2) {
-			          that.posterImage.head = res2
-			          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({
-        src: res.data.wx_head,
-        success: function (res) {
-          that.posterImage.head = res
-          that.posterLoading++
-          if (that.posterLoading === 4) {
-            that.createCtx()
-          }
-        }
-      })
+		var wxhead = res.data.wx_head;
+		if(!wxhead){
+		  wx.getUserProfile({
+			desc: '用户头像无法获取,请从新授权', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+			success: function(res3) {
+			  var url = 'xcx/save_wx_user/info'
+				console.log(JSON.stringify(res3.userInfo));
+				var params = {
+					userinfo: JSON.stringify(res3.userInfo)
+				}
+				var success = function (res4) {
+					console.log('authorize',res4)
+					wxhead = res4.data.head;
+					console.log(wxhead);
+					that.posterLoading = 0;
+					that.projectImageLoading();
+				}
+				_request.$post(url, params, success)
+			},
+			fail: function(err){
+				wx.showToast({
+				  title: '用户头像获取失败,生成海报失败',
+				  icon: 'none',
+				  duration: 2000
+				})
+				wx.hideLoading();
+				return;
+			}
+		  })
+		}else{
+			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) {
+						var url = 'v1/update/poster/' + that.data.productId
+							var params = {
+							  type: 'project'
+							}
+							var success = function (res2) {
+							  wx.getImageInfo({
+								src: res2.data.qrcode_url,
+								success: function (res2) {
+								  that.posterImage.qcode = res2
+								  that.posterLoading++
+								  if (that.posterLoading === 4) {
+									that.createCtx()
+								  }
+								},
+								fail: function (res2) {
+								  that.qcodeError = true
+								  if (that.data.posterPopup) {
+									that.setData({
+									  posterPopup: false
+									})
+									wx.showToast({
+									  title: '海报生成失败,请稍后重试',
+									  icon: 'none',
+									  duration: 2000
+									})
+									wx.hideLoading()
+								  }
+								}
+							  })
+							  wx.getImageInfo({
+								src: res2.data.wx_head,
+								success: function (res2) {
+								  that.posterImage.head = res2
+								  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({
+					src: res.data.wx_head,
+					success: function (res) {
+					  that.posterImage.head = res
+					  that.posterLoading++
+					  if (that.posterLoading === 4) {
+						that.createCtx()
+					  }
+					}
+				  })
+		}
     }
     _request.$get(url, params, success)
   },

+ 3 - 10
project.config.json

@@ -3,34 +3,27 @@
   "setting": {
     "urlCheck": true,
     "es6": true,
-    "enhance": false,
     "postcss": true,
     "preloadBackgroundData": false,
     "minified": true,
     "newFeature": true,
     "coverView": true,
-    "nodeModules": false,
     "autoAudits": false,
     "showShadowRootInWxmlPanel": true,
     "scopeDataCheck": false,
-    "uglifyFileName": false,
     "checkInvalidKey": true,
     "checkSiteMap": true,
     "uploadWithSourceMap": true,
-    "compileHotReLoad": false,
-    "useMultiFrameRuntime": false,
-    "useApiHook": true,
     "babelSetting": {
       "ignore": [],
       "disablePlugins": [],
       "outputPath": ""
     },
-    "useIsolateContext": true,
     "useCompilerModule": false,
     "userConfirmedUseCompilerModuleSwitch": false,
-    "packNpmManually": false,
-    "packNpmRelationList": [],
-    "minifyWXSS": true
+    "useMultiFrameRuntime": true,
+    "useApiHook": true,
+    "useApiHostProcess": true
   },
   "compileType": "miniprogram",
   "libVersion": "2.0.7",