Quellcode durchsuchen

feat:提交代码

longzhicheng vor 1 Jahr
Ursprung
Commit
14bae0de07

+ 1 - 0
components.d.ts

@@ -20,6 +20,7 @@ declare module '@vue/runtime-core' {
20
     CXBEmpty: typeof import('./src/components/CXBEmpty/CXBEmpty.vue')['default']
20
     CXBEmpty: typeof import('./src/components/CXBEmpty/CXBEmpty.vue')['default']
21
     CXBNotLoginButton: typeof import('./src/components/CXBNotLoginButton/CXBNotLoginButton.vue')['default']
21
     CXBNotLoginButton: typeof import('./src/components/CXBNotLoginButton/CXBNotLoginButton.vue')['default']
22
     CXBPhoneLoginButton: typeof import('./src/components/CXBPhoneLoginButton/CXBPhoneLoginButton.vue')['default']
22
     CXBPhoneLoginButton: typeof import('./src/components/CXBPhoneLoginButton/CXBPhoneLoginButton.vue')['default']
23
+    CXBPhonePopup: typeof import('./src/components/CXBPhonePopup/CXBPhonePopup.vue')['default']
23
     CXBPrivacyPopup: typeof import('./src/components/CXBPrivacyPopup/CXBPrivacyPopup.vue')['default']
24
     CXBPrivacyPopup: typeof import('./src/components/CXBPrivacyPopup/CXBPrivacyPopup.vue')['default']
24
     CXBSkuPopup: typeof import('./src/components/CXBSkuPopup/CXBSkuPopup.vue')['default']
25
     CXBSkuPopup: typeof import('./src/components/CXBSkuPopup/CXBSkuPopup.vue')['default']
25
     CXBUserINdexHeader: typeof import('./src/components/CXBUserIndexHeader/CXBUserINdexHeader.vue')['default']
26
     CXBUserINdexHeader: typeof import('./src/components/CXBUserIndexHeader/CXBUserINdexHeader.vue')['default']

+ 166 - 0
src/components/CXBPhonePopup/CXBPhonePopup.vue

@@ -0,0 +1,166 @@
1
+<template>
2
+
3
+
4
+  <view class="privacy" v-if="data.showPrivacy">
5
+    <view class="content">
6
+      <view class="title">隐私保护指引</view>
7
+      <view class="des">
8
+        在使用当前小程序服务之前,请仔细阅读
9
+        <text class="link" @click="openPrivacyContract">{{ data.privacyContractName }}</text>
10
+        。如果你同意{{ data.privacyContractName }},请点击“同意”开始使用。
11
+      </view>
12
+      <view class="btns">
13
+        <button class="item " @click="exitMiniProgram">拒绝</button>
14
+        <button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
15
+      </view>
16
+    </view>
17
+  </view>
18
+</template>
19
+
20
+<script setup lang="ts">
21
+	
22
+	
23
+const isShowOverlay = ref(true)
24
+
25
+const props = defineProps({
26
+  show: {
27
+    type: Boolean,
28
+    default: false
29
+  },
30
+  today: {
31
+    type: Number,
32
+    default: 0
33
+  },
34
+  day: {
35
+    type: Number,
36
+    default: 0
37
+  }
38
+})
39
+
40
+const show = ref(props.show || false)
41
+
42
+
43
+// 同意隐私协议
44
+function handleAgreePrivacyAuthorization() {
45
+  // const that = this;
46
+  wx.requirePrivacyAuthorize({
47
+    success: res => {
48
+      data.showPrivacy = false;
49
+      uni.setStorageSync('PRIVACY', {
50
+        privacyContractName: data.privacyContractName,
51
+        showPrivacy: false
52
+      })
53
+      // getApp().globalData.showPrivacy = false;
54
+    }
55
+  });
56
+}
57
+
58
+
59
+// 拒绝隐私协议
60
+function exitMiniProgram() {
61
+  const that = this;
62
+  uni.showModal({
63
+    content: '如果拒绝,我们将无法获取您的信息, 包括手机号、位置信息、相册等该小程序十分重要的功能,您确定要拒绝吗?',
64
+    success: res => {
65
+      if (res.confirm) {
66
+        that.showPrivacy = false;
67
+        uni.exitMiniProgram({
68
+          success: () => {
69
+            console.log('退出小程序成功');
70
+          }
71
+        });
72
+      }
73
+    }
74
+  });
75
+}
76
+// 跳转协议页面
77
+function openPrivacyContract() {
78
+  wx.openPrivacyContract({
79
+    fail: () => {
80
+      uni.showToast({
81
+        title: '网络错误',
82
+        icon: 'error'
83
+      });
84
+    }
85
+  });
86
+}
87
+
88
+</script>
89
+
90
+<style lang="scss" scoped>
91
+.privacy {
92
+  position: fixed;
93
+  top: 0;
94
+  right: 0;
95
+  bottom: 0;
96
+  left: 0;
97
+  background: rgba(0, 0, 0, 0.5);
98
+  z-index: 9999999;
99
+  display: flex;
100
+  align-items: center;
101
+  justify-content: center;
102
+  .content {
103
+    width: 85vw;
104
+    padding: 50rpx;
105
+    box-sizing: border-box;
106
+    background: #fff;
107
+    border-radius: 16rpx;
108
+    .title {
109
+      text-align: center;
110
+      color: #333;
111
+      font-weight: bold;
112
+      font-size: 34rpx;
113
+    }
114
+    .des {
115
+      font-size: 26rpx;
116
+      color: #666;
117
+      margin-top: 40rpx;
118
+      text-align: justify;
119
+      line-height: 1.6;
120
+      .link {
121
+        color: #F94032;
122
+        text-decoration: underline;
123
+      }
124
+    }
125
+    .btns {
126
+      margin-top: 60rpx;
127
+      display: flex;
128
+      justify-content: space-between;
129
+      .item {
130
+        justify-content: space-between;
131
+        width: 244rpx;
132
+        height: 80rpx;
133
+        display: flex;
134
+        align-items: center;
135
+        justify-content: center;
136
+        border-radius: 16rpx;
137
+        box-sizing: border-box;
138
+        border: none;
139
+        border: 1px solid #ccc;
140
+
141
+      }
142
+      .reject {
143
+        background: #f4f4f5;
144
+        color: #909399;
145
+      }
146
+      .agree {
147
+        background: #F94032;
148
+        color: #fff;
149
+      }
150
+    }
151
+  }
152
+}
153
+button {
154
+  margin: 0;
155
+  padding: 0;
156
+  outline: none;
157
+  border-radius: 0;
158
+  background-color: transparent;
159
+  line-height: inherit;
160
+}
161
+button::after {
162
+  border: none;
163
+}
164
+
165
+
166
+</style>

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
src/pages.json


+ 229 - 0
src/subPages/pages/my-profile/changePhone.vue

@@ -0,0 +1,229 @@
1
+<template>
2
+	<div  class="login-container">
3
+		<view class="input-content" >
4
+			<nut-input disabled v-model="state.oldPhone" placeholder="请输入新手机号" clearable type="number">
5
+				<template #right>
6
+					<nut-button type='primary' size="small" @click="handleGetCode" :loading="state.isAuthVerify">
7
+						{{ state.buttonText }}
8
+					</nut-button>
9
+				</template>
10
+			</nut-input>
11
+			<nut-input v-model="state.phone" placeholder="请输入新手机号" clearable type="number">
12
+			</nut-input>
13
+			<nut-input v-model="state.code" placeholder="请输入验证码" clearable type="number">
14
+			</nut-input>
15
+		</view>
16
+		<div class="flex w-full" >
17
+			<div class="p-3 w-full">
18
+				<nut-button type="primary" @click="handleLogin" block :disabled="!isFormVerify">确定</nut-button>
19
+			</div>
20
+		</div>
21
+	</div>
22
+</template>
23
+<script setup lang="ts">
24
+	import {authVerify } from "~/apis/auth.api";
25
+	import {updateUserInfo} from "~/apis/user";
26
+	import Cache from "~/utils/cache";
27
+	import { IMG_CDN_URL } from '~/config/app'
28
+	import { useUserStore } from "~/stores/userStore";
29
+	const state = reactive({
30
+		phone: '',
31
+		oldPhone:'',
32
+		code: '',
33
+		spread: '',
34
+		pwd: '',
35
+		isAuthVerify: false,
36
+		buttonText: '获取验证码',
37
+	})
38
+	
39
+	onLoad((options : any) => {
40
+		state.oldPhone = options.userPhone
41
+		console.log("===options.userPhone",options.userPhone);
42
+	})
43
+
44
+	function sendCode() {
45
+		if (state.isAuthVerify) return
46
+		state.isAuthVerify = true
47
+		let n = 60;
48
+		state.buttonText = "剩余 " + n + "s";
49
+		const run = setInterval(() => {
50
+			n = n - 1;
51
+			if (n < 0) {
52
+				clearInterval(run);
53
+				n = 0
54
+			}
55
+			state.buttonText = "剩余 " + n + "s";
56
+			if (state.buttonText === "剩余 " + 0 + "s") {
57
+				state.isAuthVerify = false;
58
+				state.buttonText = "重新获取";
59
+			}
60
+		}, 1000);
61
+	}
62
+
63
+	const isFormVerify = computed(() => {
64
+		if (state.phone !== '' && state.code !== '') {
65
+			return true
66
+		}
67
+	})
68
+	
69
+	
70
+	
71
+	function handleGetCode() {
72
+		if (!state.oldPhone) {
73
+			return uni.showToast({
74
+				title: '请填写手机号码',
75
+				icon: 'none'
76
+			})
77
+		}
78
+		if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(state.oldPhone)) {
79
+			return uni.showToast({
80
+				title: '请输入正确的手机号码',
81
+				icon: 'none'
82
+			})
83
+		}
84
+
85
+		state.isAuthVerify = true
86
+		authVerify(state.oldPhone).then(res => {
87
+			state.isAuthVerify = false
88
+			sendCode()
89
+		}).catch(res => {
90
+		})
91
+	}
92
+	
93
+	
94
+	function handleLogin() {
95
+		uni.showLoading({
96
+			title: '提交中...'
97
+		});
98
+		
99
+		if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(state.phone)) {
100
+			return uni.showToast({
101
+				title: '请输入正确的手机号码',
102
+				icon: 'none'
103
+			})
104
+		}
105
+		
106
+		let params = {
107
+			phone: state.phone,
108
+			sms_code: state.code,
109
+		}
110
+		updateUserInfo({
111
+			...params
112
+		}).then(authRes => {
113
+			uni.showToast({
114
+			  title: '修改成功',
115
+			  icon: 'none'
116
+			}).then(() => {
117
+			//	uni.$emit('isUploadInfo')
118
+			  setTimeout(() => {
119
+			    const userStore = useUserStore()
120
+			    userStore.logout()
121
+			    uni.switchTab({
122
+			        url: '/pages/home/index'
123
+			    })
124
+			  }, 200)
125
+			})
126
+		}).catch((errorMsg) => {
127
+			console.log(errorMsg)
128
+			uni.showToast({
129
+				title: errorMsg,
130
+				icon: 'none'
131
+			})
132
+		})
133
+	}
134
+	
135
+	
136
+</script>
137
+
138
+<route lang="yaml">
139
+style:
140
+  navigationBarTitleText: 修改手机号
141
+</route>
142
+
143
+<style>
144
+	page {
145
+		background: #f8f8f8;
146
+	}
147
+</style>
148
+<style scoped lang="scss">
149
+	.login-container {
150
+		display: flex;
151
+		flex-direction: column;
152
+		
153
+		
154
+		.phone-content{
155
+			display: flex;
156
+			flex-direction: column;
157
+			margin-top: 20rpx;
158
+			padding-top: 48rpx;
159
+			padding-left: 40rpx;
160
+			background: #FFFFFF;
161
+			border-radius: 8rpx 8rpx 0rpx 0rpx;
162
+		}
163
+		
164
+		.item-title{
165
+			font-size:22rpx ;
166
+			color: #7B7B7B;
167
+			margin-bottom: 28rpx;
168
+		}
169
+		
170
+		.item-value{
171
+			font-size:30rpx ;
172
+			color: #333;
173
+		}
174
+		
175
+		.item-content{
176
+			display: flex;
177
+			width: 100%;
178
+			flex-direction: row;
179
+			align-items: center;
180
+			
181
+		}
182
+		.item-line{
183
+			height: 1rpx;
184
+			color: #D8D8D8;
185
+			width: 100%;
186
+			margin-top: 36rpx;
187
+			margin-bottom: 36rpx;
188
+		}
189
+
190
+		.input-content {
191
+			display: flex;
192
+			flex-direction: column;
193
+			width:100%;
194
+		}
195
+
196
+		.logo-icon {
197
+			width: 200rpx;
198
+			height: 200rpx;
199
+			margin-top: 160rpx;
200
+			margin-bottom: 120rpx;
201
+		}
202
+
203
+		.choose-content {
204
+			display: flex;
205
+			flex-direction: row;
206
+			align-items: center;
207
+			margin-bottom: 20rpx;
208
+
209
+			.choose-item {
210
+				font-size: 32rpx;
211
+				color: #333;
212
+				padding: 20rpx;
213
+				font-weight: bolder;
214
+			}
215
+
216
+			.choose-default-item {
217
+				font-size: 32rpx;
218
+				color: #999;
219
+				padding: 20rpx;
220
+			}
221
+
222
+			.choose-line {
223
+				width: 1rpx;
224
+				background-color: #999;
225
+				height: 30rpx;
226
+			}
227
+		}
228
+	}
229
+</style>

+ 27 - 7
src/subPages/pages/my-profile/index.vue

@@ -3,7 +3,6 @@
3
 import {UPLOAD_URL} from "~/utils/http";
3
 import {UPLOAD_URL} from "~/utils/http";
4
 import {getToken} from "~/utils/auth";
4
 import {getToken} from "~/utils/auth";
5
 import {updateUserInfo} from "~/apis/user";
5
 import {updateUserInfo} from "~/apis/user";
6
-
7
 const userStore = useUserStore()
6
 const userStore = useUserStore()
8
 const showSexPicker = ref(false)
7
 const showSexPicker = ref(false)
9
 const sexPopupValue = ref()
8
 const sexPopupValue = ref()
@@ -13,7 +12,6 @@ const sexColumns = ref([
13
 ])
12
 ])
14
 
13
 
15
 const formData = reactive({
14
 const formData = reactive({
16
-  phone: '',
17
   nickname: '',
15
   nickname: '',
18
   sex: '1',
16
   sex: '1',
19
   birthday: '',
17
   birthday: '',
@@ -22,6 +20,7 @@ const formData = reactive({
22
   tempFile: { path: '' },
20
   tempFile: { path: '' },
23
   mark: ''
21
   mark: ''
24
 })
22
 })
23
+const userPhone=ref('')
25
 // const sex
24
 // const sex
26
 const sexPopupConfirm = ({ selectedValue, selectedOptions }) => {
25
 const sexPopupConfirm = ({ selectedValue, selectedOptions }) => {
27
   console.log(selectedValue)
26
   console.log(selectedValue)
@@ -50,10 +49,32 @@ onLoad(async () => {
50
     formData.sex = userInfo.sex
49
     formData.sex = userInfo.sex
51
     formData.avatar = userInfo.avatar
50
     formData.avatar = userInfo.avatar
52
     formData.mark = userInfo.mark
51
     formData.mark = userInfo.mark
53
-    formData.phone = userInfo.phone
52
+    userPhone.value = userInfo.phone
53
+	console.log("=== userPhone.value", userPhone.value);
54
   }
54
   }
55
+  
56
+  // uni.$on('isUploadInfo',async ()=>{
57
+  // 	 await userStore.getUserInfo()
58
+  // 	 console.log(userStore.userInfo)
59
+  // 	if (userStore.userInfo) {
60
+  // 	  const userInfo = userStore.userInfo
61
+  // 	  formData.nickname = userInfo.nickname
62
+  // 	  formData.birthday = userInfo.birthday
63
+  // 	  formData.sex = userInfo.sex
64
+  // 	  formData.avatar = userInfo.avatar
65
+  // 	  formData.mark = userInfo.mark
66
+  // 	  userPhone.value = userInfo.phone
67
+  // 	}
68
+  // })
55
 })
69
 })
56
 
70
 
71
+function onPhoneClick(){
72
+	console.log("===userPhone.value",userPhone.value);
73
+	uni.navigateTo({
74
+		url:`/subPages/pages/my-profile/changePhone?userPhone=${userPhone.value}`
75
+	})
76
+}
77
+
57
 function onChooseAvatar({ detail }) {
78
 function onChooseAvatar({ detail }) {
58
   console.log()
79
   console.log()
59
   formData.avatar = detail.avatarUrl
80
   formData.avatar = detail.avatarUrl
@@ -99,10 +120,8 @@ function handleSubmit() {
99
     avatar: formData.avatar,
120
     avatar: formData.avatar,
100
     nickname: formData.nickname,
121
     nickname: formData.nickname,
101
     sex: formData.sex,
122
     sex: formData.sex,
102
-    // birthday: formData.birthday,
103
     birthday: currentDate.value,
123
     birthday: currentDate.value,
104
     mark: formData.mark,
124
     mark: formData.mark,
105
-	phone: formData.phone
106
   }).then(res => {
125
   }).then(res => {
107
     if (res) {
126
     if (res) {
108
       uni.showToast({
127
       uni.showToast({
@@ -199,8 +218,8 @@ function handleSubmit() {
199
     <div
218
     <div
200
         class="bg-white rounded-md text-sm flex justify-between p-3  f-hairline-bottom">
219
         class="bg-white rounded-md text-sm flex justify-between p-3  f-hairline-bottom">
201
       <div class="">手机号</div>
220
       <div class="">手机号</div>
202
-      <div class="flex items-center">
203
-        <div><input placeholder="请填写手机号" v-model="formData.phone" class="text-right"/></div>
221
+      <div class="flex items-center" @click="onPhoneClick">
222
+        <div><input disabled="true" placeholder="请填写手机号" v-model="userPhone" class="text-right"/></div>
204
         <div
223
         <div
205
             class="f-text-color-2 i-tabler-chevron-right transform transition-300"
224
             class="f-text-color-2 i-tabler-chevron-right transform transition-300"
206
         />
225
         />
@@ -228,6 +247,7 @@ function handleSubmit() {
228
     </div>
247
     </div>
229
 
248
 
230
   </div>
249
   </div>
250
+  
231
 </template>
251
 </template>
232
 
252
 
233
 
253
 

+ 1 - 0
uni-pages.d.ts

@@ -113,6 +113,7 @@ interface NavigateToOptions {
113
        "/subPages/pages/movies/nearbyCinemas" |
113
        "/subPages/pages/movies/nearbyCinemas" |
114
        "/subPages/pages/movies/orderDetail" |
114
        "/subPages/pages/movies/orderDetail" |
115
        "/subPages/pages/movies/orderList" |
115
        "/subPages/pages/movies/orderList" |
116
+       "/subPages/pages/my-profile/changePhone" |
116
        "/subPages/pages/my-profile/index" |
117
        "/subPages/pages/my-profile/index" |
117
        "/subPages/pages/order/comment" |
118
        "/subPages/pages/order/comment" |
118
        "/subPages/pages/order/detail" |
119
        "/subPages/pages/order/detail" |