diff --git a/api/public.js b/api/public.js index 18a095a..296496b 100644 --- a/api/public.js +++ b/api/public.js @@ -41,6 +41,18 @@ export function wechatAuth(code, spread, login_type) { ); } +export function userMerge(data) { + return request.post( + "user/merge", data, { + noAuth: true + } + ); +} + +/** + * 微信第一次登录绑定原有用户/新用户 + * + */ export function commonAuth(data) { return request.post( "auth", data, { @@ -48,6 +60,7 @@ export function commonAuth(data) { } ); } + /** * 获取登录授权login * diff --git a/manifest.json b/manifest.json index f27ee50..c06dcb9 100644 --- a/manifest.json +++ b/manifest.json @@ -114,13 +114,13 @@ "payment" : { "weixin" : { "__platform__" : [ "ios", "android" ], - "appid" : "wx9d68c92b550ddd1e", + "appid" : "wx2e8f79ff281284f5", "UniversalLinks" : "https://shop.lihaink.cn/" } }, "share" : { "weixin" : { - "appid" : "wx9d68c92b550ddd1e", + "appid" : "wx2e8f79ff281284f5", "UniversalLinks" : "https://shop.lihaink.cn/" } }, @@ -134,7 +134,7 @@ }, "oauth" : { "weixin" : { - "appid" : "wx9d68c92b550ddd1e", + "appid" : "wx2e8f79ff281284f5", "UniversalLinks" : "https://shop.lihaink.cn/" } }, diff --git a/pages/redpacket/redpack_type.vue b/pages/redpacket/redpack_type.vue index b5385ab..6fd580c 100644 --- a/pages/redpacket/redpack_type.vue +++ b/pages/redpacket/redpack_type.vue @@ -20,9 +20,9 @@ {{item.type_cn}} - + @@ -55,7 +55,7 @@ uni.navigateBack(); }, navgo(item){ - return ; + // return ; if(item.type==1) uni.navigateTo({ url: '/pages/newActivity/subsidy/subsidy2' }) diff --git a/pages/users/login/login_copy.vue b/pages/users/login/login_copy.vue index 1c5aeaf..b02958f 100644 --- a/pages/users/login/login_copy.vue +++ b/pages/users/login/login_copy.vue @@ -209,7 +209,7 @@ - + @@ -274,7 +274,8 @@ } from "@/utils"; import parser from "@/components/jyf-parser/jyf-parser"; import { - commonAuth + commonAuth, + userMerge } from '../../../api/public'; import { mapGetters @@ -858,6 +859,90 @@ import { Toast } from "../../../libs/uniApi"; }); }); }, + async weixinMerge() { + let that = this; + if (!that.account) return that.$util.Tips({ + title: '请输入手机号码' + }); + if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({ + title: '请输入正确的手机号码' + }); + if (!that.captcha) return that.$util.Tips({ + title: '请输入验证码' + }); + if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({ + title: '请输入正确的验证码' + }); + if (!that.password) return that.$util.Tips({ + title: '请输入密码' + }); + if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/i.test(that.password)) return that.$util.Tips({ + title: '请输入6-16位字母加数字组合' + }); + if (!that.isAgree) return that.$util.Tips({ + title: '请勾选用户协议与隐私政策' + }); + console.log('绑定前', { + auth_token: this.auth_token || uni.getStorageSync('auth_token'), + phone: that.account, + sms_code: that.captcha, + pwd: that.password, + spread: that.$Cache.get("spread"), + // #ifdef APP-PLUS + user_type: 'app', + // #endif + // #ifdef H5 + user_type: 'h5', + // #endif + }); + userMerge({ + auth_token: this.auth_token || uni.getStorageSync('auth_token'), + phone: that.account, + sms_code: that.captcha, + pwd: that.password, + spread: that.$Cache.get("spread"), + // #ifdef APP-PLUS + user_type: 'app', + // #endif + // #ifdef H5 + user_type: 'h5', + // #endif + }) + .then(res => { + console.log(res); + that.$store.commit("LOGIN", { + 'token': res.data.token, + 'time': res.data.exp + }); + that.$store.commit("SETUID", res.data.user.uid); + that.$store.commit('UPDATE_USERINFO', res.data.user); + const backUrl = that.$Cache.get('login_back_url_weixin') || that.$Cache.get(BACK_URL) || "/pages/index/index"; + that.$Cache.clear(BACK_URL); + that.$Cache.clear('login_back_url_weixin'); + let method + let indexPat = ['/pages/index/index', '/pages/order_addcart/order_addcart', + '/pages/goods_cate/goods_cate', + '/pages/user/index' + ] + if (indexPat.includes(this.getPath(backUrl))) { + method = 'switchTab' + } else { + method = 'navigateTo' + } + uni[method]({ + url: backUrl, + success:()=>{ + this.auth_token = '' + } + }); + }) + .catch(res => { + console.log('error', err); + that.$util.Tips({ + title: res + }); + }); + }, async code(data) { let that = this; if (!that.account) return that.$util.Tips({