风险测评小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
5.7 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page__view">
  3. <navbar />
  4. <view class="flex flex-column header">
  5. <image class="icon" :src="configList.app_logo" mode="widthFix"></image>
  6. <!-- <image class="icon" src="@/static/image/icon.png" mode="widthFix"></image> -->
  7. <view class="name">
  8. {{ configList.app_name || '' }}
  9. </view>
  10. <view class="title">
  11. 申请获取你的头像昵称
  12. </view>
  13. </view>
  14. <view class="form">
  15. <view class="form-item">
  16. <view class="label">
  17. 头像
  18. </view>
  19. <view class="content">
  20. <button class="btn-avatar" :plain="true" :hairline="false" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  21. <image class="avatar" v-if="userInfoForm.headImage" :src="userInfoForm.headImage" mode=""></image>
  22. <image class="avatar" v-else src="@/pages_order/static/auth/avatar-default.png" mode="scaleToFill"></image>
  23. </button>
  24. </view>
  25. </view>
  26. <view class="form-item">
  27. <view class="label">
  28. 昵称
  29. </view>
  30. <view class="content">
  31. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  32. placeholder-class="uni-placeholder"
  33. v-model="userInfoForm.nickName"
  34. />
  35. </view>
  36. </view>
  37. <view class="form-item">
  38. <view class="label">
  39. 手机号
  40. </view>
  41. <view class="flex content" style="justify-content: flex-end; column-gap: 31rpx;">
  42. <input
  43. v-model="userInfoForm.phone"
  44. style="text-align: right;"
  45. disabled
  46. />
  47. <button
  48. :plain="true" :hairline="false"
  49. class="btn-phone"
  50. open-type="getPhoneNumber"
  51. @getphonenumber="getPhone"
  52. >
  53. 获取手机号
  54. </button>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="footer">
  59. <button class="btn" @click="submit">
  60. 确定
  61. </button>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. export default {
  67. data() {
  68. return {
  69. userInfoForm: {
  70. headImage: '',
  71. nickName: '',
  72. phone: '',
  73. }
  74. };
  75. },
  76. onShow() {},
  77. onLoad() {
  78. this.userInfoForm.nickName = this.userInfo.nickName || ''
  79. this.userInfoForm.headImage = this.userInfo.headImage || ''
  80. },
  81. computed: {},
  82. methods: {
  83. onChooseAvatar(res) {
  84. this.$Oss.ossUpload(res.target.avatarUrl)
  85. .then(url => {
  86. this.userInfoForm.headImage = url
  87. })
  88. },
  89. getPhone(e){
  90. this.$api('bindPhone', {
  91. phoneCode : e.detail.code
  92. }, res => {
  93. if(res.code == 200){
  94. let phoneObj = JSON.parse(res.result)
  95. if(phoneObj.errmsg == 'ok'){
  96. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  97. }else{
  98. uni.showModal({
  99. title: phoneObj.errmsg
  100. })
  101. }
  102. }
  103. })
  104. },
  105. submit() {
  106. let self = this
  107. uni.createSelectorQuery().in(this)
  108. .select("#nickName")
  109. .fields({
  110. properties: ["value"],
  111. })
  112. .exec((res) => {
  113. const nickName = res?.[0]?.value
  114. self.userInfoForm.nickName = nickName
  115. if (self.$utils.verificationAll(self.userInfoForm, {
  116. headImage: '请选择头像',
  117. nickName: '请填写昵称',
  118. phone: '请填写手机号',
  119. })) {
  120. return
  121. }
  122. self.$api('updateInfo', {
  123. headImage : self.userInfoForm.headImage,
  124. nickName : self.userInfoForm.nickName,
  125. phone : self.userInfoForm.phone,
  126. }, res => {
  127. if (res.code == 200) {
  128. uni.reLaunch({
  129. url:'/pages/index/index'
  130. })
  131. }
  132. })
  133. })
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .page__view {
  140. display: flex;
  141. justify-content: flex-start;
  142. align-items: center;
  143. height: 100vh;
  144. flex-direction: column;
  145. position: relative;
  146. .header{
  147. padding: 187rpx 0 106rpx 0;
  148. .icon {
  149. width: 100rpx;
  150. height: auto;
  151. }
  152. .name {
  153. margin: 20rpx 0 14rpx 0;
  154. font-size: 36rpx;
  155. font-family: PingFang SC, PingFang SC-Bold;
  156. font-weight: 700;
  157. text-align: center;
  158. color: #000000;
  159. }
  160. .title {
  161. font-size: 30rpx;
  162. font-family: PingFang SC, PingFang SC-Regular;
  163. font-weight: 400;
  164. color: #000000;
  165. }
  166. }
  167. .form {
  168. padding: 0 48rpx;
  169. box-sizing: border-box;
  170. width: 100%;
  171. .form-item {
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-between;
  175. width: 100%;
  176. min-height: 119rpx;
  177. padding: 0 22rpx 0 13rpx;
  178. position: relative;
  179. border-top: 1rpx solid rgba($color: #C7C7C7, $alpha: 0.33);
  180. &:last-child {
  181. border-bottom: 1rpx solid rgba($color: #C7C7C7, $alpha: 0.33);
  182. }
  183. .label {
  184. white-space: nowrap;
  185. font-size: 32rpx;
  186. font-weight: 400;
  187. text-align: left;
  188. color: #000000;
  189. }
  190. .content {
  191. flex: 1;
  192. text-align: right;
  193. }
  194. }
  195. .btn-avatar {
  196. background: transparent;
  197. border: none;
  198. border-radius: none;
  199. box-shadow: none;
  200. padding: 0;
  201. margin: 0;
  202. font-size: 0;
  203. text-align: right;
  204. }
  205. .avatar {
  206. display: inline-block;
  207. width: 97rpx;
  208. height: 97rpx;
  209. }
  210. .btn-phone {
  211. display: inline-block;
  212. width: auto;
  213. margin: 0;
  214. padding: 23rpx 33rpx;
  215. font-size: 30rpx;
  216. line-height: 1.4;
  217. color: #FFFFFF;
  218. background: #014FA2;
  219. border: none;
  220. border-radius: 38rpx;
  221. }
  222. }
  223. .btn {
  224. text-align: center;
  225. margin-top: 155rpx;
  226. width: 80%;
  227. height: 100rpx;
  228. border-radius: 50rpx;
  229. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  230. color: #fff;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. border-radius: 50rpx;
  235. border: none;
  236. }
  237. }
  238. .footer {
  239. margin-top: 200rpx;
  240. width: 100%;
  241. padding: 0 78rpx;
  242. box-sizing: border-box;
  243. .btn {
  244. width: 100%;
  245. padding: 25rpx 0;
  246. box-sizing: border-box;
  247. font-size: 32rpx;
  248. color: #FFFFFF;
  249. background: #014FA2;
  250. border-radius: 41rpx;
  251. }
  252. }
  253. </style>