珠宝小程序前端代码
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.

210 lines
4.3 KiB

3 months ago
1 month ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="login">
  3. <!-- <view class="logo">
  4. <image :src="configList.logo_image" mode=""></image>
  5. </view> -->
  6. <view class="title">
  7. {{ configList.logo_name }}
  8. </view>
  9. <view class="title">
  10. 申请获取你的头像昵称
  11. </view>
  12. <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  13. <view class="line">
  14. <view class="">
  15. 头像
  16. </view>
  17. <view class="">
  18. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" style="width: 60rpx;height: 60rpx;"
  19. mode=""></image>
  20. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode=""></image>
  21. </view>
  22. </view>
  23. </button>
  24. <view class="line">
  25. <view class="">
  26. 昵称
  27. </view>
  28. <view class="">
  29. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  30. v-model="userInfoForm.nickName" />
  31. </view>
  32. </view>
  33. <view class="line">
  34. <view class="">
  35. 手机号
  36. </view>
  37. <view class=""
  38. v-if="userInfoForm.phone">
  39. <input placeholder="请输入手机号" style="text-align: right;"
  40. disabled
  41. v-model="userInfoForm.phone" />
  42. </view>
  43. <view class=""
  44. v-else>
  45. <button
  46. class="getPhoneNumber"
  47. open-type="getPhoneNumber"
  48. @getphonenumber="getPhone">
  49. 获取电话号码
  50. </button>
  51. </view>
  52. </view>
  53. <view class="btn" @click="submit">
  54. 确认
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. userInfoForm: {
  63. headImage: '',
  64. nickName: '',
  65. phone : '',
  66. }
  67. };
  68. },
  69. onShow() {},
  70. onLoad() {
  71. this.userInfoForm.phone = this.userInfo.phone || ''
  72. this.userInfoForm.nickName = this.userInfo.nickName || ''
  73. this.userInfoForm.headImage = this.userInfo.headImage || ''
  74. },
  75. computed: {},
  76. methods: {
  77. onChooseAvatar(res) {
  78. this.$Oss.ossUpload(res.target.avatarUrl)
  79. .then(url => {
  80. this.userInfoForm.headImage = url
  81. })
  82. },
  83. getPhone(e){
  84. this.$api('bindPhone', {
  85. phoneCode : e.detail.code
  86. }, res => {
  87. if(res.code == 200){
  88. let phoneObj = JSON.parse(res.result)
  89. if(phoneObj.errmsg == 'ok'){
  90. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  91. }else{
  92. uni.showModal({
  93. title: phoneObj.errmsg
  94. })
  95. }
  96. console.log(phoneObj);
  97. }
  98. })
  99. },
  100. submit() {
  101. let self = this
  102. uni.createSelectorQuery().in(this)
  103. .select("#nickName")
  104. .fields({
  105. properties: ["value"],
  106. })
  107. .exec((res) => {
  108. const nickName = res?.[0]?.value
  109. self.userInfoForm.nickName = nickName
  110. if (self.$utils.verificationAll(self.userInfoForm, {
  111. headImage: '请选择头像',
  112. nickName: '请填写昵称',
  113. phone: '请填写手机号',
  114. })) {
  115. return
  116. }
  117. self.$api('updateInfo', {
  118. avatarUrl : self.userInfoForm.headImage,
  119. nickName : self.userInfoForm.nickName,
  120. phone : self.userInfoForm.phone,
  121. }, res => {
  122. if (res.code == 200) {
  123. uni.reLaunch({
  124. url:'/pages/index/index'
  125. })
  126. }
  127. })
  128. })
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .login {
  135. display: flex;
  136. flex-direction: column;
  137. justify-content: center;
  138. align-items: center;
  139. height: 80vh;
  140. .logo{
  141. height: 140rpx;
  142. width: 140rpx;
  143. image{
  144. height: 140rpx;
  145. width: 140rpx;
  146. border-radius: 30rpx;
  147. }
  148. margin-bottom: 20rpx;
  149. }
  150. .title {
  151. line-height: 45rpx;
  152. font-weight: 900;
  153. }
  154. .line {
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. width: 80%;
  159. border-bottom: 1px solid #00000023;
  160. padding: 30rpx 0;
  161. margin: 0 auto;
  162. }
  163. .chooseAvatar {
  164. width: 100%;
  165. padding: 0;
  166. margin: 0;
  167. margin-top: 10vh;
  168. border: none;
  169. }
  170. .btn {
  171. // background: $uni-linear-gradient-btn-color;
  172. background: $uni-color;
  173. color: #fff;
  174. width: 80%;
  175. padding: 20rpx 0;
  176. text-align: center;
  177. border-radius: 15rpx;
  178. margin-top: 10vh;
  179. }
  180. .getPhoneNumber{
  181. // all: unset;
  182. display: flex;
  183. justify-content: center;
  184. align-items: center;
  185. // background: $uni-linear-gradient-btn-color;
  186. background: $uni-color;
  187. color: #fff;
  188. width: 200rpx;
  189. height: 60rpx;
  190. border-radius: 30rpx;
  191. font-size: 24rpx;
  192. }
  193. }
  194. </style>