Browse Source

解决签名错误问题

DESKTOP-SYIYI\Dell 7 years ago
parent
commit
907e72b640

File diff suppressed because it is too large
+ 1 - 1
dist/index.html


File diff suppressed because it is too large
+ 0 - 2
dist/mshop/js/app.079e43c4aa05de800f70.js


File diff suppressed because it is too large
+ 0 - 1
dist/mshop/js/app.079e43c4aa05de800f70.js.map


File diff suppressed because it is too large
+ 2 - 0
dist/mshop/js/app.89571efb08b33ab6fc1d.js


File diff suppressed because it is too large
+ 1 - 0
dist/mshop/js/app.89571efb08b33ab6fc1d.js.map


File diff suppressed because it is too large
+ 2 - 2
dist/mshop/js/manifest.c0fa7e28959a6372ba8c.js


File diff suppressed because it is too large
+ 1 - 1
dist/mshop/js/manifest.c0fa7e28959a6372ba8c.js.map


File diff suppressed because it is too large
+ 0 - 1
dist/mshop/js/vendor.8901a790766246d187fb.js.map


File diff suppressed because it is too large
+ 5 - 5
dist/mshop/js/vendor.8901a790766246d187fb.js


File diff suppressed because it is too large
+ 1 - 0
dist/mshop/js/vendor.caf7311e59699205ce6c.js.map


+ 1 - 1
src/components/goods/goods_detail.vue

@@ -149,7 +149,7 @@
                     link: host + '/mobile/index.php?act=mshop&op=goods&goods_id='+goods_id,
                     img_url: this.getOneSummary['goods_image_url']
                 };
-                let WxShare = Api.create_share(shareMsg,Api.sign_url(location.href))
+                let WxShare = Api.create_share(shareMsg)
             },(err) => {
                 this.$vux.toast.show({
                 type: 'text',

+ 2 - 3
src/components/main/home/homeList.vue

@@ -9,11 +9,10 @@
             let shareMsg = {
                 title: '熊猫美妆商城',
                 desc: '丽人丽妆 内买商城',
-                link: "http://" + window.location.host + '/mobile/index.php?act=mshop&op=index',
+                link: window.location.protocol + '//'+ window.location.host + '/mobile/index.php?act=mshop&op=index',
                 img_url: 'http://p.lrlz.com/data/resource/mobile/defimg/panda.jpeg'
             };
-            let WxShare = Api.create_share(shareMsg,Api.sign_url(window.location.href));
-            alert(123);
+            let WxShare = Api.create_share(shareMsg);
         },
         datas(){
             return {url: ""}

+ 10 - 9
src/components/special/special_list.vue

@@ -3,6 +3,7 @@
     import {Divider} from 'vux'
     import Api from "../../lib/api.js"
     import WechatShare from '../../wechat/WechatShare'
+    import {base64} from 'vux'
 
 
     export default
@@ -10,15 +11,15 @@
         created() {
             this.getNewData();
             let isSpecial = this.$route.query.is_special;
-            let title = this.$route.query.title;
+            let title = base64.decode(this.$route.query.title);
+            let special_id = this.$route.query["special_id"];
             let shareMsg;
-            if (isSpecial)
-            {
-                let host = window.location.protocol + '//' + window.location.host;
+            let host = window.location.protocol + '//' + window.location.host;
+            if (isSpecial) {
                 shareMsg = {
                     title: title,
                     desc: '丽人丽妆 内买商城',
-                    link: host + '/mobile/index.php?act=mshop&op=special&special_id=' + this.special_id + "&title=" + encodeURIComponent(title),
+                    link: host + '/mobile/index.php?act=mshop&op=special&special_id=' + special_id + "&title=" + this.$route.query.title,
                     img_url: host + '/data/resource/mobile/defimg/panda.jpeg'
                 };
             } else {
@@ -30,7 +31,7 @@
                 };
 
             }
-            let WxShare = Api.create_share(shareMsg,Api.sign_url(window.location.href));
+            let WxShare = Api.create_share(shareMsg);
         },
         data(){
             return {
@@ -60,9 +61,9 @@
                 params.hot_id = this.$route.query["hot_id"];
                 params.brand_id = this.$route.query["brand_id"];
                 params.keyword = this.$route.query["keyword"];
-                let title = this.$route.query["title"];
+                let title = base64.decode(this.$route.query["title"]);
                 if (params.is_special == false || params.is_special == 'false') {
-                    this.url = Api.host() + '/mobile/index.php?act=search&op=index&client_type=ajax&title='+title;
+                    this.url = Api.host() + '/mobile/index.php?act=search&op=index&client_type=ajax&title=' + title;
                     for (let i in params) {
                         if (params[i] !== 'undefined') {
                             this.url += "&" + i + '=' + params[i] + "";
@@ -83,7 +84,7 @@
                     }
                 ],
                 domProps: {
-                    innerHTML: this.$route.query["title"] || this.$route.query["keyword"]
+                    innerHTML: base64.decode(this.$route.query["title"]) || this.$route.query["keyword"]
                 }
             });
             let special_id = this.$route.query["special_id"];

+ 2 - 2
src/lib/Actions.js

@@ -28,7 +28,7 @@ class Actions {
             query: {
                 special_id: special_id,
                 is_special: true,
-                title: title
+                title: base64.encode(title)
             }
         };
     }
@@ -39,7 +39,7 @@ class Actions {
             query: {
                 special_id: special_id,
                 is_special: false,
-                title: title,
+                 title: base64.encode(title),
                 hot_id: hot_id,
                 brand_id: brand_id,
                 keyword: keyword

+ 24 - 24
src/lib/api.js

@@ -5,28 +5,27 @@ let enter_url = "";
 let gWxShare = null;
 
 let mobile = {
-    Android: function() {
+    Android: function () {
         return navigator.userAgent.match(/Android/i);
     },
-    BlackBerry: function() {
+    BlackBerry: function () {
         return navigator.userAgent.match(/BlackBerry/i);
     },
-    iOS: function() {
+    iOS: function () {
         return navigator.userAgent.match(/iPhone|iPad|iPod/i);
     },
-    Opera: function() {
+    Opera: function () {
         return navigator.userAgent.match(/Opera Mini/i);
     },
-    Windows: function() {
+    Windows: function () {
         return navigator.userAgent.match(/IEMobile/i);
     },
-    any: function() {
+    any: function () {
         return (mobile.Android() || mobile.BlackBerry() || mobile.iOS() || mobile.Opera() || mobile.Windows());
     }
 };
 
-class Api
-{
+class Api {
     static host() {
         return envHost;
     }
@@ -149,31 +148,32 @@ class Api
         return this.host() + `/mobile/index.php?act=member_order&op=pay_info&curpage=1&pay_sn=${pay_sn}&client_type=ajax`;
     }
 
-    static init_url(href)
-    {
-        enter_url = href;
+    static init_url() {
+        if (enter_url == "") {
+            enter_url = window.location.href;
+        }
     }
-    static create_share(data,href)
-    {
-        if(mobile.iOS())
-        {
-            gWxShare = new WechatShare(data,href);
 
+    static create_share(data, href) {
+        if (mobile.iOS()) {
+            gWxShare = new WechatShare(data, this.sign_url());
             return gWxShare;
         }
-        else
-        {
-            return new WechatShare(data,href);
+        else {
+            return new WechatShare(data, this.sign_url());
         }
     }
 
-    static sign_url(href)
-    {
-        if(mobile.iOS()) {
-            return href;
+    static sign_url() {
+        let temp;
+        if (mobile.iOS()) {
+            Api.init_url();
+            temp = enter_url;
         } else {
-            return href;
+            temp = window.location.href;
         }
+
+        return decodeURIComponent(temp);
     }
 
 }

+ 16 - 18
src/main.js

@@ -35,11 +35,11 @@ const store = new Vuex.Store({
             action_id: -1
         },
         user_bonus: [],
-        address:{
-            aid:'',
-            name:'',
-            mobile:'',
-            address:''
+        address: {
+            aid: '',
+            name: '',
+            mobile: '',
+            address: ''
         },
     },
     mutations: {
@@ -76,19 +76,19 @@ const store = new Vuex.Store({
 Vue.http.interceptors.push((request, next) => {
     let timeout;
 // 這裡改用 _timeout
-if (request._timeout) {
-    timeout = setTimeout(() => {
+    if (request._timeout) {
+        timeout = setTimeout(() => {
             //自定义响应体 status:408,statustext:"请求超时",并返回给下下边的next
             next(request.respondWith(request.body, {
-            status: 408,
-            statusText: '请求超时'
-        }));
-
-}, request._timeout);
-}
-next((response) => {
-return response;
-})
+                status: 408,
+                statusText: '请求超时'
+            }));
+
+        }, request._timeout);
+    }
+    next((response) => {
+        return response;
+    })
 });
 
 //
@@ -114,7 +114,6 @@ const router = new VueRouter({
 });
 //
 router.beforeEach(function (to, from, next) {
-
     if (to.path.indexOf("schema") !== -1) {
         let schema = base64.decode(to.query.schema);
         let urlObj = CommonUtil.parseURL(schema);
@@ -131,7 +130,6 @@ router.beforeEach(function (to, from, next) {
     }
 });
 
-
 FastClick.attach(document.body);
 
 Vue.config.productionTip = false;

+ 4 - 5
src/wechat/WechatShare.js

@@ -2,20 +2,19 @@
  * Created by huanggang on 2017/5/26.
  */
 import Vue from 'vue'
-import {WechatPlugin} from 'vux'
+import {WechatPlugin, base64} from 'vux'
+
 Vue.use(WechatPlugin);
 
 class WechatShare {
     constructor(data, surl) {
         let sign_url = encodeURIComponent(surl.split('#')[0]);
         let host = window.location.protocol + '//' + window.location.host;
-        alert(sign_url);
         let url = host + "/mobile/index.php?act=mshop&op=signurl&client_type=ajax&sign_url=" + sign_url + "&callback=";
 
         let pThis = this;
         this.getJSONP(url, function (res) {
             if (res.code !== 200) {
-                // alert(res.message);
                 return;
             }
             let sign = res.datas;
@@ -24,7 +23,7 @@ class WechatShare {
                 signature = sign.signature,
                 appid = sign.appid;
             Vue.wechat.config({
-                debug: true,
+                debug: false,
                 appId: appid,
                 timestamp: timestamp,
                 nonceStr: nonceStr,
@@ -107,7 +106,7 @@ class WechatShare {
             });
 
             Vue.wechat.error(function (res) {
-                alert(res.errMsg);
+                console.log(res)
             });
         })
     }

BIN
vueWorkSpace.lnk