建材商城系统20241014
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.

213 lines
4.3 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 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. if(!e.detail.code){
  85. return
  86. }
  87. this.$api('bindPhone', {
  88. code : e.detail.code
  89. }, res => {
  90. if(res.code == 200){
  91. let phoneObj = JSON.parse(res.result)
  92. if(phoneObj.errmsg == 'ok'){
  93. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  94. }else{
  95. uni.showModal({
  96. title: phoneObj.errmsg
  97. })
  98. }
  99. console.log(phoneObj);
  100. }
  101. })
  102. },
  103. submit() {
  104. let self = this
  105. uni.createSelectorQuery().in(this)
  106. .select("#nickName")
  107. .fields({
  108. properties: ["value"],
  109. })
  110. .exec((res) => {
  111. const nickName = res?.[0]?.value
  112. self.userInfoForm.nickName = nickName
  113. if (self.$utils.verificationAll(self.userInfoForm, {
  114. headImage: '请选择头像',
  115. nickName: '请填写昵称',
  116. phone: '请填写手机号',
  117. })) {
  118. return
  119. }
  120. self.$api('updateInfo', {
  121. headImage : self.userInfoForm.headImage,
  122. nickName : self.userInfoForm.nickName,
  123. phone : self.userInfoForm.phone,
  124. }, res => {
  125. if (res.code == 200) {
  126. uni.reLaunch({
  127. url:'/pages/index/index'
  128. })
  129. }
  130. })
  131. })
  132. },
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .login {
  138. display: flex;
  139. flex-direction: column;
  140. justify-content: center;
  141. align-items: center;
  142. height: 80vh;
  143. .logo{
  144. height: 140rpx;
  145. width: 140rpx;
  146. image{
  147. height: 140rpx;
  148. width: 140rpx;
  149. border-radius: 30rpx;
  150. }
  151. margin-bottom: 20rpx;
  152. }
  153. .title {
  154. line-height: 45rpx;
  155. font-weight: 900;
  156. }
  157. .line {
  158. display: flex;
  159. justify-content: space-between;
  160. align-items: center;
  161. width: 80%;
  162. border-bottom: 1px solid #00000023;
  163. padding: 30rpx 0;
  164. margin: 0 auto;
  165. }
  166. .chooseAvatar {
  167. width: 100%;
  168. padding: 0;
  169. margin: 0;
  170. margin-top: 10vh;
  171. border: none;
  172. }
  173. .btn {
  174. // background: $uni-linear-gradient-btn-color;
  175. background: $uni-color;
  176. color: #fff;
  177. width: 80%;
  178. padding: 20rpx 0;
  179. text-align: center;
  180. border-radius: 15rpx;
  181. margin-top: 10vh;
  182. }
  183. .getPhoneNumber{
  184. // all: unset;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. // background: $uni-linear-gradient-btn-color;
  189. background: $uni-color;
  190. color: #fff;
  191. width: 200rpx;
  192. height: 60rpx;
  193. border-radius: 30rpx;
  194. font-size: 24rpx;
  195. }
  196. }
  197. </style>