更新了微信授权登录
This commit is contained in:
parent
e06d250588
commit
b5b1be3d39
@ -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) {
|
export function commonAuth(data) {
|
||||||
return request.post(
|
return request.post(
|
||||||
"auth", data, {
|
"auth", data, {
|
||||||
@ -48,6 +60,7 @@ export function commonAuth(data) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录授权login
|
* 获取登录授权login
|
||||||
*
|
*
|
||||||
|
@ -114,13 +114,13 @@
|
|||||||
"payment" : {
|
"payment" : {
|
||||||
"weixin" : {
|
"weixin" : {
|
||||||
"__platform__" : [ "ios", "android" ],
|
"__platform__" : [ "ios", "android" ],
|
||||||
"appid" : "wx9d68c92b550ddd1e",
|
"appid" : "wx2e8f79ff281284f5",
|
||||||
"UniversalLinks" : "https://shop.lihaink.cn/"
|
"UniversalLinks" : "https://shop.lihaink.cn/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"share" : {
|
"share" : {
|
||||||
"weixin" : {
|
"weixin" : {
|
||||||
"appid" : "wx9d68c92b550ddd1e",
|
"appid" : "wx2e8f79ff281284f5",
|
||||||
"UniversalLinks" : "https://shop.lihaink.cn/"
|
"UniversalLinks" : "https://shop.lihaink.cn/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -134,7 +134,7 @@
|
|||||||
},
|
},
|
||||||
"oauth" : {
|
"oauth" : {
|
||||||
"weixin" : {
|
"weixin" : {
|
||||||
"appid" : "wx9d68c92b550ddd1e",
|
"appid" : "wx2e8f79ff281284f5",
|
||||||
"UniversalLinks" : "https://shop.lihaink.cn/"
|
"UniversalLinks" : "https://shop.lihaink.cn/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
<view class="r_content">
|
<view class="r_content">
|
||||||
<view class="r_name">{{item.type_cn}}</view>
|
<view class="r_name">{{item.type_cn}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="r_btn">
|
<view class="r_btn">
|
||||||
查看
|
查看
|
||||||
</view> -->
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -55,7 +55,7 @@
|
|||||||
uni.navigateBack();
|
uni.navigateBack();
|
||||||
},
|
},
|
||||||
navgo(item){
|
navgo(item){
|
||||||
return ;
|
// return ;
|
||||||
if(item.type==1) uni.navigateTo({
|
if(item.type==1) uni.navigateTo({
|
||||||
url: '/pages/newActivity/subsidy/subsidy2'
|
url: '/pages/newActivity/subsidy/subsidy2'
|
||||||
})
|
})
|
||||||
|
@ -209,7 +209,7 @@
|
|||||||
</checkbox-group>
|
</checkbox-group>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<button form-type="submit" @click="register" class="confirmBnt">确认绑定</button>
|
<button form-type="submit" @click="weixinMerge" class="confirmBnt">确认绑定</button>
|
||||||
<button form-type="submit" @click="auth_token = ''" class="confirmBnt back">返回</button>
|
<button form-type="submit" @click="auth_token = ''" class="confirmBnt back">返回</button>
|
||||||
</view>
|
</view>
|
||||||
</form>
|
</form>
|
||||||
@ -274,7 +274,8 @@
|
|||||||
} from "@/utils";
|
} from "@/utils";
|
||||||
import parser from "@/components/jyf-parser/jyf-parser";
|
import parser from "@/components/jyf-parser/jyf-parser";
|
||||||
import {
|
import {
|
||||||
commonAuth
|
commonAuth,
|
||||||
|
userMerge
|
||||||
} from '../../../api/public';
|
} from '../../../api/public';
|
||||||
import {
|
import {
|
||||||
mapGetters
|
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) {
|
async code(data) {
|
||||||
let that = this;
|
let that = this;
|
||||||
if (!that.account) return that.$util.Tips({
|
if (!that.account) return that.$util.Tips({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user