Browse Source

上传代码

v1
前端-胡立永 9 months ago
parent
commit
7ebb4cf0c5
5 changed files with 74 additions and 40 deletions
  1. +23
    -8
      components/showLogin/showLogin.vue
  2. +19
    -11
      pages/center/center.vue
  3. +15
    -14
      pages/login/wxUserInfo.vue
  4. +11
    -4
      pages/payment/payment.vue
  5. +6
    -3
      store/store.js

+ 23
- 8
components/showLogin/showLogin.vue View File

@ -1,5 +1,7 @@
<template> <template>
<uni-popup ref="popup" type="bottom" border-radius="10px 10px 0 0">
<uv-popup ref="popup"
:safeAreaInsetBottom="false"
type="bottom" round="30rpx">
<view class="toast"> <view class="toast">
<view class="title"> <view class="title">
提示 提示
@ -7,16 +9,13 @@
<view class="content"> <view class="content">
本小程序需要登录之后才可以正常使用 本小程序需要登录之后才可以正常使用
</view> </view>
<view class="btnstwo">
<view class="btn c" @click="cancel">
取消
</view>
<view class="btn c" @click="$store.commit('login')">
<view class="btns">
<view class="btn c" @click="login">
登录 登录
</view> </view>
</view> </view>
</view> </view>
</uni-popup>
</uv-popup>
</template> </template>
<script setup> <script setup>
@ -37,6 +36,10 @@
cancel() { cancel() {
this.$refs.popup.close('center') this.$refs.popup.close('center')
},
login(){
this.$store.commit('login')
this.$refs.popup.close('center')
} }
} }
} }
@ -57,12 +60,24 @@
.content { .content {
font-size: 28rpx; font-size: 28rpx;
min-height: 300rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.btns{
display: flex;
padding: 30rpx;
.btn{
flex: 1;
background: #00aaff;
border-radius: 20rpx;
color: #fff;
padding: 20rpx 0;
text-align: center;
}
}
.btnstwo { .btnstwo {
display: flex; display: flex;


+ 19
- 11
pages/center/center.vue View File

@ -4,11 +4,21 @@
<view class="content"> <view class="content">
<view class="topBox"> <view class="topBox">
<view class="users"> <view class="users">
<view class="u-top">
<view class="u-top" v-if="userInfo.appletOpenid">
<image
:src="userInfo.headImage"
mode=""></image>
<view class="tit"
>
{{ userInfo.nickName }}
</view>
</view>
<view class="u-top" v-else>
<image <image
src="https://img2.baidu.com/it/u=2953585264,744730101&fm=253&fmt=auto&app=138&f=JPEG?w=360&h=360" src="https://img2.baidu.com/it/u=2953585264,744730101&fm=253&fmt=auto&app=138&f=JPEG?w=360&h=360"
mode=""></image> mode=""></image>
<view class="tit">
<view class="tit"
>
登录 / 注册 登录 / 注册
</view> </view>
</view> </view>
@ -49,25 +59,23 @@
<script> <script>
import showLogin from '../../components/showLogin/showLogin.vue' import showLogin from '../../components/showLogin/showLogin.vue'
import { mapState } from 'vuex'
export default { export default {
name : 'Center', name : 'Center',
components : { showLogin }, components : { showLogin },
computed : {
...mapState(['userInfo']),
},
data() { data() {
return {} return {}
}, },
onShow(){ onShow(){
this.getUserInfo()
if (!this.$refs.login.checkLogin()) {
this.$store.commit('getUserInfo')
}
}, },
methods: { methods: {
//
getUserInfo(){
this.$api('infoGetInfo', res => {
console.log(res);
})
}
} }
} }
</script> </script>


+ 15
- 14
pages/login/wxUserInfo.vue View File

@ -66,20 +66,21 @@
.exec((res) => { .exec((res) => {
const nickName = res?.[0]?.value const nickName = res?.[0]?.value
self.userInfo.nickName = nickName self.userInfo.nickName = nickName
if (self.$utils.verificationAll(self.userInfo, {
headImage: '请选择头像',
nickName: '请填写昵称',
})) {
return
}
self.$api('infoUpdateInfo', self.userInfo, res => {
if (res.code == 200) {
uni.navigateBack(-1)
}
})
}) })
if (this.$utils.verificationAll(this.userInfo, {
headImage: '请选择头像',
nickName: '请填写昵称',
})) {
return
}
this.$api('infoUpdateInfo', this.userInfo, res => {
if (res.code == 200) {
uni.navigateBack(-1)
}
})
}, },
} }
} }
@ -118,7 +119,7 @@
.btn { .btn {
// background: $uni-linear-gradient-btn-color; // background: $uni-linear-gradient-btn-color;
background: lightblue;
background: #00aaff;
color: #fff; color: #fff;
width: 80%; width: 80%;
padding: 20rpx 0; padding: 20rpx 0;


+ 11
- 4
pages/payment/payment.vue View File

@ -20,9 +20,13 @@
</view> </view>
<view v-if="form.money" class="tip"> <view v-if="form.money" class="tip">
折后共计{{ form.money * 0.99 }}
折后共计{{
form.money *
(configList.preferential ?
configList.preferential.keyCentent
: 1)
}}
</view> </view>
<view class="select-money"> <view class="select-money">
<view v-for="(item, index) in rechargeList" class="money-item" :key="index"> <view v-for="(item, index) in rechargeList" class="money-item" :key="index">
<view @click="selectMoney(item.price,index)" :class="{ 'active-money' : currentIndex == index }" <view @click="selectMoney(item.price,index)" :class="{ 'active-money' : currentIndex == index }"
@ -49,13 +53,16 @@
<script setup> <script setup>
import PrivacyAgreementPoup from "../../components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue"; import PrivacyAgreementPoup from "../../components/PrivacyAgreementPoup/PrivacyAgreementPoup.vue";
import showLogin from "../../components/showLogin/showLogin.vue"; import showLogin from "../../components/showLogin/showLogin.vue";
import { mapState } from 'vuex'
export default { export default {
name: 'Payment', name: 'Payment',
component: { component: {
PrivacyAgreementPoup, PrivacyAgreementPoup,
showLogin showLogin
}, },
computed : {
...mapState(['configList']),
},
data() { data() {
return { return {
form: { form: {
@ -88,7 +95,7 @@
this.getRechargePage() this.getRechargePage()
}, },
methods: { methods: {
// //
selectMoney(money, item) { selectMoney(money, item) {
this.form.money = money this.form.money = money


+ 6
- 3
store/store.js View File

@ -9,12 +9,13 @@ import api from '@/api/api.js'
const store = new Vuex.Store({ const store = new Vuex.Store({
state: { state: {
configList: {}, //配置对象 configList: {}, //配置对象
userInfo : {},
}, },
getters: {}, getters: {},
mutations: { mutations: {
// 初始化配置 // 初始化配置
initConfig(state) { initConfig(state) {
let config = ['discount', 'wx']
let config = ['preferential', 'wx']
config.forEach(k => { config.forEach(k => {
api('getConfig', { api('getConfig', {
keyValue : k keyValue : k
@ -53,9 +54,11 @@ const store = new Vuex.Store({
} }
}) })
}, },
getUserInfo() {
getUserInfo(state) {
api('infoGetInfo', res => { api('infoGetInfo', res => {
console.log(res);
if(res.code == 200){
state.userInfo = res.result
}
}) })
}, },
}, },


Loading…
Cancel
Save