谢杰标 hace 3 años
padre
commit
102534e154

+ 18 - 14
.hbuilderx/launch.json

@@ -1,16 +1,20 @@
-{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
-  // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
-    "version": "0.0",
-    "configurations": [{
-     	"default" : 
-     	{
-     		"launchtype" : "local"
-     	},
-     	"mp-weixin" : 
-     	{
-     		"launchtype" : "local"
-     	},
-     	"type" : "uniCloud"
-     }
+{
+    // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/
+    // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数
+    "version" : "0.0",
+    "configurations" : [
+        {
+            "default" : {
+                "launchtype" : "local"
+            },
+            "mp-weixin" : {
+                "launchtype" : "local"
+            },
+            "type" : "uniCloud"
+        },
+        {
+            "playground" : "standard",
+            "type" : "uni-app:app-android"
+        }
     ]
 }

+ 72 - 0
common/authorize.js

@@ -0,0 +1,72 @@
+import { getWxConfig, getMobileConfig, OfficialLogin } from "@/utils/user";
+export function getQueryString(name) {
+  const url = location.search; //获取url中"?"符后的字串
+  let theRequest = new Object();
+  if (url.indexOf("?") != -1) {
+    let str = url.substr(1);
+    let strs = str.split("&");
+    for (let i = 0; i < strs.length; i++) {
+      theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
+    }
+  }
+  if (name) {
+    return theRequest[name];
+  }
+  return theRequest;
+}
+// 授权
+export function authorize(url = window.location.href) {
+  if (!isWechat()) {
+    return;
+  }
+  if (uni.getStorageSync("code")) {
+    return;
+  }
+  // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
+  // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
+  getMobileConfig().then((res) => {
+    if (JSON.parse(res.mobileConfig).gzhSelfLicense) {
+      getWxConfig().then((res) => {
+        location.replace(
+          `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${
+            res.gzhAppId
+          }&redirect_uri=${encodeURIComponent(
+            "https://" + url
+          )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
+        );
+      });
+    } else {
+      url = url.split("//")[1];
+      location.replace("https://www.xyyxt.net/home/index2?ask_type=" + url);
+    }
+  });
+}
+export function bindCode(code) {
+  if (!uni.getStorageSync("user_account")) {
+    return;
+  }
+  OfficialLogin({
+    code,
+  }).then((res) => {
+    
+  });
+}
+
+// url获取code
+export function backCode(cb = bindCode) {
+  let code = uni.getStorageSync("code");
+  if (code) {
+    cb(code);
+  }
+  if (!location.search.includes("code")) {
+    return;
+  }
+  code = getQueryString("code");
+  uni.setStorageSync("code", code);
+  cb(code);
+}
+
+export function isWechat() {
+  var ua = window.navigator.userAgent.toLowerCase();
+  return ua.match(/micromessenger/i) == "micromessenger";
+}

+ 2 - 2
common/config.js

@@ -1,7 +1,7 @@
 // test 测试环境
 
 const dev = {
-  BASE_URL: "http://192.168.1.7:5030",
+  BASE_URL: "http://120.79.166.78:19013",
   BASE_IMG_URL: "https://file-dev.xyyxt.net/",
 };
 
@@ -11,7 +11,7 @@ const index = 0; // 测试环境
 const set = [
   dev,
   {
-    BASE_URL: "http://120.79.166.78:19012",
+    BASE_URL: "http://120.79.166.78:19013",
     BASE_IMG_URL: "https://file-dev.xyyxt.net/",
   },
   {

+ 0 - 21
common/tool.js

@@ -68,24 +68,3 @@ export function checkDomain(str) {
     /^([\w-]+\.)+((com)|(net)|(org)|(gov\.cn)|(info)|(cc)|(com\.cn)|(net\.cn)|(org\.cn)|(name)|(biz)|(tv)|(cn)|(mobi)|(name)|(sh)|(ac)|   (io)|(tw)|(com\.tw)|(hk)|(com\.hk)|(ws)|(travel)|(us)|(tm)|(la)|(me\.uk)|(org\.uk)|(ltd\.uk)|(plc\.uk)|(in)|(eu)|(it)|(jp))$/;
   return domain.test(str);
 }
-
-export function getQueryString(name) {
-  const url = location.search; //获取url中"?"符后的字串
-  let theRequest = new Object();
-  if (url.indexOf("?") != -1) {
-    let str = url.substr(1);
-    let strs = str.split("&");
-    for (let i = 0; i < strs.length; i++) {
-      theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
-    }
-  }
-  if (name) {
-    return theRequest[name];
-  }
-  return theRequest;
-}
-
-export function isWechat() {
-  var ua = window.navigator.userAgent.toLowerCase();
-  return ua.match(/micromessenger/i) == "micromessenger";
-}

+ 47 - 27
common/wechat.js

@@ -6,16 +6,30 @@ export default {
     var ua = window.navigator.userAgent.toLowerCase();
     return ua.match(/micromessenger/i) == "micromessenger";
   },
+  jsApiList: [
+    "updateTimelineShareData",
+    "updateAppMessageShareData",
+    "onMenuShareAppMessage",
+    "onMenuShareTimeline",
+  ],
   //初始化sdk配置
   initJssdkShare: function (callback) {
-    getShareGzh().then((result) => {
+    getShareGzh({
+      url: window.location.href,
+    }).then((result) => {
       jweixin.config({
-        debug: true,
+        debug: false,
         appId: result.appid,
-        timestamp: result.timestamp,
+        timestamp: result.timeStamp,
         nonceStr: result.nonceStr,
         signature: result.signature,
-        jsApiList: ["updateTimelineShareData", "updateAppMessageShareData"],
+        jsApiList: this.jsApiList,
+      });
+      jweixin.checkJsApi({
+        jsApiList: this.jsApiList,
+        success: function (res) {
+          console.log(res, 7897);
+        },
       });
       //配置完成后,再执行分享等功能
       if (callback) {
@@ -25,29 +39,35 @@ export default {
   },
   //在需要自定义分享的页面中调用
   share: function (data) {
-    // if (!this.isWechat()) {
-    //   return;
-    // }
-    //每次都需要重新初始化配置,才可以进行分享
-    this.initJssdkShare(function (signData) {
-      let { title, desc, link, imgUrl } = data;
-      jweixin.ready(function () {
-        
-        var shareData = {
-          title,
-          desc,
-          link: link || window.location.href,
-          imgUrl,
-          success: function (res) {
-            // 分享后的一些操作,比如分享统计等等
-            console.log("分享成功");
-          },
-          cancel: function (res) {},
-        };
-        //分享给朋友接口
-        // jweixin.updateAppMessageShareData(shareData);
-        //分享到朋友圈接口
-        jweixin.updateTimelineShareData(shareData);
+    return new Promise((resolve, reject) => {
+      if (!this.isWechat()) {
+        reject();
+      }
+      this.initJssdkShare(function (signData) {
+        let { title, desc, link, imgUrl } = data;
+        jweixin.ready(function () {
+          var shareData = {
+            title,
+            desc,
+            link: link || window.location.href,
+            imgUrl,
+            success: function (res) {
+              resolve(res);
+            },
+            cancel: function (res) {},
+          };
+          // 旧的
+          // 分享给朋友接口
+          jweixin.onMenuShareAppMessage(shareData);
+          // 分享到朋友圈
+          jweixin.onMenuShareTimeline(shareData);
+
+          // 新的
+          // 分享给朋友接口
+          // jweixin.updateAppMessageShareData(shareData);
+          // //分享到朋友圈接口
+          // jweixin.updateTimelineShareData(shareData);
+        });
       });
     });
   },

+ 11 - 1
pages.json

@@ -113,5 +113,15 @@
   "uniIdRouter": {},
   "easycom": {
     "^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
-  }
+  },
+	"condition" : { //模式配置,仅开发期间生效
+		"current": 0, //当前激活的模式(list 的索引项)
+		"list": [
+			{
+				"name": "", //模式名称
+				"path": "", //启动页面,必选
+				"query": "" //启动参数,在页面的onLoad函数里面得到
+			}
+		]
+	}
 }

+ 28 - 7
pages/bill/index.vue

@@ -40,7 +40,9 @@
 </template>
 
 <script>
-import { getSharePoster } from "@/utils/bill";
+import { getSharePoster, bindLink } from "@/utils/bill";
+import { authorize, backCode } from "@/common/authorize";
+import { openidLogin } from "@/utils/login";
 import tkiQrcode from "tki-qrcode";
 import wechat from "@/common/wechat";
 export default {
@@ -57,6 +59,10 @@ export default {
     this.getSharePoster();
     this.share();
     uni.setStorageSync("BillHerf", window.location.href);
+    authorize();
+  },
+  onShow() {
+    backCode(this.login);
   },
   components: {
     tkiQrcode,
@@ -103,13 +109,28 @@ export default {
         item[e] = this.px2rpx(item[e]);
       });
     },
+    bindLink() {
+      bindLink({
+        linkCode: this.options.linkCode,
+        distributionId: this.options.distributionId,
+      });
+    },
     share() {
-      //分享微信好友
-      wechat.share({
-        title: "穷期先生的名片",
-        desc: "拥有多年财富管理经验的理财专家",
-        imgUrl: "",
-        link: "h.xyyxt.net",
+      wechat
+        .share({
+          title: "杨大毛非常帅",
+          desc: "JAVA超级专家",
+          imgUrl: "",
+          link: window.location.href,
+        })
+        .then((res) => {
+          this.$method.isLogin() && this.bindLink();
+        });
+    },
+    login(code) {
+      openidLogin({ openid: code }).then((data) => {
+        this.$store.commit("LOGIN_CB", data);
+        this.$store.dispatch("getUserInfo");
       });
     },
   },

+ 12 - 37
pages/cashout/index.vue

@@ -61,13 +61,8 @@
 
 <script>
 import { mapGetters } from "vuex";
-import { getQueryString } from "@/common/tool";
-import {
-  checkBindGzh,
-  getWxConfig,
-  OfficialLogin,
-  withdrawal,
-} from "@/utils/user";
+import { authorize, backCode } from "@/common/authorize";
+import { checkBindGzh, withdrawal } from "@/utils/user";
 export default {
   data() {
     return {
@@ -77,7 +72,7 @@ export default {
     };
   },
   onShow() {
-    location.search.includes("code") && this.OfficialLogin();
+    backCode();
   },
   onLoad(options) {
     if (this.$method.isGoLogin()) {
@@ -110,12 +105,15 @@ export default {
     },
     // 获取授权
     checkBindGzh() {
-      return checkBindGzh().then((res) => {
-        if (res || process.env.NODE_ENV == "development") {
-          return Promise.resolve();
-        } else {
-          this.authorize();
-        }
+      return new Promise((resolve, reject) => {
+        checkBindGzh().then((res) => {
+          if (res || process.env.NODE_ENV == "development") {
+            resolve();
+          } else {
+            authorize();
+            reject();
+          }
+        });
       });
     },
     toRecord() {
@@ -123,29 +121,6 @@ export default {
         url: "/pages/cashout/record",
       });
     },
-    authorize() {
-      // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=https://api.xyyxt.net/pages2/order/confirm_pay 去获取code,授权后就会把code带上然后访问域名
-      // ?fromCart=&code=061F5a1w3aolh03SLe1w3sMsCF4F5a16&state=STATE
-      const url = window.location.host + "/pages/cashout/index";
-      getWxConfig().then((res) => {
-        location.replace(
-          `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${
-            res.gzhAppId
-          }&redirect_uri=${encodeURIComponent(
-            "https://" + url
-          )}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`
-        );
-      });
-    },
-    OfficialLogin() {
-      OfficialLogin({
-        code: getQueryString("code"),
-      }).then((res) => {
-        if (res.data.code !== 200) {
-          this.$u.toast(res.data.msg);
-        }
-      });
-    },
     withdrawal() {
       if (!this.money) {
         this.$u.toast("请输入提现金额");

+ 6 - 1
pages/login/login.vue

@@ -108,6 +108,7 @@
 <script>
 import { encryptor } from "@/common/jse";
 import { loginSms, accountLogin, smsLogin } from "@/utils/login";
+import { authorize, backCode } from "@/common/authorize";
 export default {
   data() {
     return {
@@ -178,8 +179,11 @@ export default {
   },
   onLoad(options) {
     this.options = options;
+    authorize();
+  },
+  onShow() {
+    backCode();
   },
-  onShow() {},
   onReady() {
     this.$refs.uForm1.setRules(this.rules);
     this.$refs.uForm2.setRules(this.rules);
@@ -264,6 +268,7 @@ export default {
       this.current = index;
     },
     loginCallback(data) {
+      backCode()
       this.$store.commit("LOGIN_CB", data);
       this.$store.dispatch("getUserInfo").then((res) => {
         if (this.options.backBill) {

+ 6 - 1
pages/login/register.vue

@@ -67,6 +67,7 @@
 <script>
 import { encryptor } from "@/common/jse";
 import { registerUser, registerSms, accountLogin } from "@/utils/login";
+import { authorize, backCode } from "@/common/authorize";
 export default {
   data() {
     return {
@@ -137,7 +138,6 @@ export default {
       options: {},
     };
   },
-  mounted() {},
   methods: {
     submit() {
       this.$refs.uForm
@@ -152,6 +152,7 @@ export default {
                 content: "注册成功",
                 showCancel: false,
                 success: (resst) => {
+                  backCode()
                   accountLogin({
                     account: this.form.tel,
                     pwd: encryptor(this.form.pwd),
@@ -219,6 +220,10 @@ export default {
       this.$refs.uForm.setRules(this.rules);
     });
     this.options = options;
+    authorize();
+  },
+  onShow() {
+    backCode();
   },
 };
 </script>

+ 1 - 1
store/index.js

@@ -33,7 +33,7 @@ const store = new Vuex.Store({
       return new Promise(async (resolve) => {
         const res = await getInfo(data);
         commit("SET_USERINFO", res);
-        resolve();
+        resolve(res);
       });
     },
   },

+ 1 - 1
unpackage/dist/build/h5/index.html

@@ -1,2 +1,2 @@
 <!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>saas_manager</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
-            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/static/index.63b34199.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.0bcb0f8b.js></script><script src=/static/js/index.a7c9da08.js></script></body></html>
+            document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/static/index.63b34199.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.0bcb0f8b.js></script><script src=/static/js/index.7b11bd3c.js></script></body></html>

+ 10 - 1
utils/bill.js

@@ -17,4 +17,13 @@ export function getShareGzh(data) {
     data: data,
     noToken: true,
   });
-}
+}
+
+//绑定分销链路
+export function bindLink(data) {
+  return myRequest({
+    url: "/system/link",
+    method: "post",
+    data,
+  });
+}

+ 10 - 0
utils/login.js

@@ -26,6 +26,16 @@ export function accountLogin(data) {
     noToken: true,
   });
 }
+//账号登录用户
+export function openidLogin(data) {
+  return myRequest({
+    url: "/app/common/seller/openid_login",
+    method: "post",
+    data: data,
+    noToken: true,
+  });
+}
+
 //登录用户信息
 export function getInfo(data) {
   return myRequest({

+ 25 - 0
utils/user.js

@@ -16,6 +16,14 @@ export function getInfoByShareCode(data) {
   });
 }
 
+export function getWxConfig(data) {
+  return myRequest({
+    url: "/app/common/wx/config",
+    method: "get",
+    data: data,
+    noToken: true,
+  });
+}
 // 查询用户是否绑定公众号
 export function checkBindGzh(data) {
   return myRequest({
@@ -34,6 +42,14 @@ export function withdrawal(data) {
   });
 }
 
+export function OfficialLogin(data) {
+  return myRequest({
+    url: "/distribution/seller/gzh_bind",
+    method: "post",
+    data: data,
+  });
+}
+
 // 提现记录
 export function getWithdrawalList(data) {
   return myRequest({
@@ -42,3 +58,12 @@ export function getWithdrawalList(data) {
     data: data,
   });
 }
+
+export function getMobileConfig(data) {
+  return myRequest({
+    url: "/app/common/mobileConfig",
+    method: "get",
+    data: data,
+    noToken: true,
+  });
+}