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

214 lines
4.4 KiB

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