From 9e64414d16f734926468e58362ef515ab29890bb Mon Sep 17 00:00:00 2001
From: lin <1005713861@163.com>
Date: Mon, 20 Apr 2026 17:03:36 +0800
Subject: [PATCH] feat: 星享购用户默认头像更换;更改头像功能隐藏;优化统一名称pig-token
---
pages/login/login.vue | 223 +++++++++++++++++++++++++++++++++++--------------------
1 files changed, 141 insertions(+), 82 deletions(-)
diff --git a/pages/login/login.vue b/pages/login/login.vue
index b14533a..5dbcb6b 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -12,7 +12,7 @@
</view>
<view class="login-list">
<view class="login-item">
- <input type="tel" v-model="formData.phone" placeholder="请输入手机号" />
+ <input type="tel" v-model="formData.phone" maxlength="11" placeholder="请输入手机号" />
</view>
<view class="login-item" v-if="formData.loginType == 1">
<input type="password" v-model="formData.pass" placeholder="请输入密码" />
@@ -25,7 +25,7 @@
</view>
<view class="loginBtn">
<view class="loginBtn-desc">
- <image @click="agreeClick" class="loginBtn-icon" :src="!loginAct ? '/static/imgs/check.png' : '/static/imgs/checked.png'" ></image>
+ <image @click="agreeClick" class="loginBtn-icon" :src="!loginAct ? '/static/imgs/check.png' : '/static/imgs/checked.png'" mode=""></image>
<text>我已阅读并同意</text>
<text class="blue" @tap="agreeDialog1">《注册协议》</text>
<text class="blue" @tap="agreeDialog2">《隐私政策》</text>
@@ -77,103 +77,162 @@
agreeClick () {
this.loginAct = !this.loginAct
},
- async loginUser() {
- let t = this
+ // loginUser () {
+ // let t = this
+ // if(!t.loginAct) {
+ // return uni.showToast({
+ // title: '请阅读并同意协议政策',
+ // icon: 'error'
+ // })
+ // }
+ // if(t.formData.phone == '' || !t.phoneReg.test(t.formData.phone)){
+ // return uni.showToast({
+ // title: '手机号错误!',
+ // icon: 'error',
+ // })
+ // }
+ // if(t.formData.pass == '' && t.formData.loginType == 1){
+ // return uni.showToast({
+ // title: '请输入密码!',
+ // icon: 'error',
+ // })
+ // }
+ // if(t.formData.code == '' && t.formData.loginType == 2){
+ // return uni.showToast({
+ // title: '请输入验证码!',
+ // icon: 'error',
+ // })
+ // }
+ // t.$util.post('User/Login', this.formData).then(res => {
+ // if(res.code == 1) {
+ // uni.setStorageSync('pig-token', res.data.userToken)
+ // uni.setStorageSync('user-info', JSON.stringify(res.data))
+ // let isSwitch = 0
+ // let goUrl = ''
+ // if(this.backUrl == ''){
+ // isSwitch = 1
+ // goUrl = '/pages/index/index'
+ // } else {
+ // goUrl = this.backUrl
+ // }
+ // uni.showToast({
+ // title: res.msg || '登录成功'
+ // })
+ // setTimeout(() => {
+ // if(isSwitch == 1) {
+ // t.$util.goSwitch(goUrl)
+ // } else {
+ // t.$util.goPages(goUrl)
+ // }
+ // }, 1500)
+ // } else {
+ // uni.showToast({
+ // title: res.msg || '登录失败',
+ // icon: 'error'
+ // })
+ // }
+ // })
+ // },
+ async loginUser() {
+ let t = this
- if (!t.loginAct) {
- return uni.showToast({
- title: '请阅读并同意协议政策',
- icon: 'error'
- })
- }
+ if (!t.loginAct) {
+ return uni.showToast({
+ title: '请阅读并同意协议政策',
+ icon: 'error'
+ })
+ }
- if (t.formData.phone == '' || !t.phoneReg.test(t.formData.phone)) {
- return uni.showToast({
- title: '手机号错误!',
- icon: 'error'
- })
- }
+ if (t.formData.phone == '' || !t.phoneReg.test(t.formData.phone)) {
+ return uni.showToast({
+ title: '手机号错误!',
+ icon: 'error'
+ })
+ }
- if (t.formData.pass == '' && t.formData.loginType == 1) {
- return uni.showToast({
- title: '请输入密码!',
- icon: 'error'
- })
- }
+ if (t.formData.pass == '' && t.formData.loginType == 1) {
+ return uni.showToast({
+ title: '请输入密码!',
+ icon: 'error'
+ })
+ }
- if (t.formData.code == '' && t.formData.loginType == 2) {
- return uni.showToast({
- title: '请输入验证码!',
- icon: 'error'
- })
- }
+ if (t.formData.code == '' && t.formData.loginType == 2) {
+ return uni.showToast({
+ title: '请输入验证码!',
+ icon: 'error'
+ })
+ }
- try {
+ try {
- // 登录接口
- const res = await t.$util.post('User/Login', this.formData)
+ // 登录接口
+ const res = await t.$util.post('User/Login', this.formData)
- if (res.code == 1) {
+ if (res.code == 1) {
- uni.setStorageSync('lzsc-token', res.data.userToken)
- uni.setStorageSync('user-info', JSON.stringify(res.data))
+ uni.setStorageSync('pig-token', res.data.userToken)
+ uni.setStorageSync('user-info', JSON.stringify(res.data))
- let isSwitch = 0
- let goUrl = ''
+ let isSwitch = 0
+ let goUrl = ''
- // qxgLogin接口
- const ygxRes = await new Promise((resolve, reject) => {
- uni.request({
- url: t.$webHost + '/api/v2/auth/qxgIosUnionLogin?phone=' + t.$util.getUserInfo().phone,
- success: resolve,
- fail: reject
- })
- })
- console.log(ygxRes);
- if(!ygxRes.data.data.boughtEquity){
- goUrl = '/pages/quanyi/index'
- t.$util.goPages(goUrl)
- return
- }
+ // qxgLogin接口
+ const ygxRes = await new Promise((resolve, reject) => {
+ uni.request({
+ url: t.$webHost + '/api/v2/auth/qxgIosUnionLogin?phone=' + t.$util.getUserInfo().phone,
+ success: resolve,
+ fail: reject
+ })
+ })
+ console.log(ygxRes);
+ // if(!ygxRes.data.data.boughtEquity){
+ // goUrl = '/pages/quanyi/index'
+ // // t.$util.goPages(goUrl)
+ // uni.navigateTo({
+ // url: '/pages/quanyi/index'
+ // })
+ // return
+ // }
- t.qxgLogin = ygxRes.data.data
- uni.setStorageSync('qxgLogin', t.qxgLogin)
+ t.ygxLogin = ygxRes.data.data
+ uni.setStorageSync('ygxLogin', t.ygxLogin)
- if (this.backUrl == '') {
- isSwitch = 1
- goUrl = '/pages/index/index'
- } else {
- goUrl = this.backUrl
- }
+ if (this.backUrl == '') {
+ isSwitch = 1
+ goUrl = '/pages/index/index'
+ } else {
+ goUrl = this.backUrl
+ }
- uni.showToast({
- title: res.msg || '登录成功'
- })
+ uni.showToast({
+ title: res.msg || '登录成功'
+ })
- setTimeout(() => {
- if (isSwitch == 1) {
- t.$util.goSwitch(goUrl)
- } else {
- t.$util.goPages(goUrl)
- }
- }, 1500)
+ setTimeout(() => {
+ if (isSwitch == 1) {
+ t.$util.goSwitch(goUrl)
+ } else {
+ t.$util.goPages(goUrl)
+ }
+ }, 1500)
- } else {
- uni.showToast({
- title: res.msg || '登录失败',
- icon: 'error'
- })
- }
+ } else {
+ uni.showToast({
+ title: res.msg || '登录失败',
+ icon: 'error'
+ })
+ }
- } catch (err) {
- console.error(err)
+ } catch (err) {
+ console.error(err)
- uni.showToast({
- title: '请求失败',
- icon: 'error'
- })
- }
- },
+ uni.showToast({
+ title: '请求失败',
+ icon: 'error'
+ })
+ }
+ },
sendCode () {
let t = this
if(this.formData.phone == '' || !this.phoneReg.test(t.formData.phone)){
--
Gitblit v1.9.3