敢为人鲜小程序前端代码仓库
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.

243 lines
5.2 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
8 months ago
10 months ago
8 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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="logo">
  7. <image src="@/static/image/logo.webp" mode="aspectFill"></image>
  8. </view>
  9. <view class="title" v-if="configList.config_logo">
  10. {{ configList.config_app_name }}
  11. </view>
  12. <view class="app-name" v-else>
  13. 敢为人鲜
  14. </view>
  15. <view class="title">
  16. 申请获取您的头像昵称
  17. </view>
  18. <button class=" reset-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" style="margin-top: 80rpx;">
  19. <view class="line" style="border-top: 2rpx solid #00000020;">
  20. <view class="">
  21. 头像
  22. </view>
  23. <view class="">
  24. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" style="width: 60rpx;height: 60rpx;"
  25. mode="" />
  26. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode="" />
  27. </view>
  28. </view>
  29. </button>
  30. <view class="line">
  31. <view class="">
  32. 昵称
  33. </view>
  34. <view class="">
  35. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  36. v-model="userInfoForm.nickName" />
  37. </view>
  38. </view>
  39. <view class="line">
  40. <view class="">
  41. 手机号
  42. </view>
  43. <view class=""
  44. v-if="userInfoForm.phone">
  45. <input placeholder="请输入手机号" style="text-align: right;"
  46. disabled
  47. v-model="userInfoForm.phone" />
  48. </view>
  49. <view class=""
  50. v-else>
  51. <button
  52. class="getPhoneNumber reset-button"
  53. open-type="getPhoneNumber"
  54. @getphonenumber="getPhone">
  55. 获取手机号
  56. </button>
  57. </view>
  58. </view>
  59. <view class="btn" @tap="submit">
  60. 确定
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. export default {
  66. data() {
  67. return {
  68. userInfoForm: {
  69. headImage: '',
  70. nickName: '',
  71. phone : '',
  72. }
  73. };
  74. },
  75. onShow() {},
  76. onLoad() {
  77. this.userInfoForm.phone = this.userInfo.phone || ''
  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. console.log(phoneObj);
  96. if (phoneObj.errmsg == 'ok'){
  97. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  98. }
  99. // let phoneObj = JSON.parse(res.result)
  100. // if(phoneObj.errmsg == 'ok'){
  101. // this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  102. // }else{
  103. // uni.showModal({
  104. // title: phoneObj.errmsg
  105. // })
  106. // }
  107. // console.log(phoneObj);
  108. }
  109. })
  110. },
  111. submit() {
  112. let self = this
  113. uni.createSelectorQuery().in(this)
  114. .select("#nickName")
  115. .fields({
  116. properties: ["value"],
  117. })
  118. .exec((res) => {
  119. const nickName = res?.[0]?.value
  120. self.userInfoForm.nickName = nickName
  121. if (self.$utils.verificationAll(self.userInfoForm, {
  122. headImage: '请选择头像',
  123. nickName: '请填写昵称',
  124. phone: '请填写手机号',
  125. })) {
  126. return
  127. }
  128. // 更新个人资料函数
  129. self.$api('updateUser', {
  130. headImage : self.userInfoForm.headImage,
  131. nickName : self.userInfoForm.nickName,
  132. phone : self.userInfoForm.phone,
  133. }, res => {
  134. if (res.code == 200) {
  135. this.$store.commit('getUserInfo')
  136. uni.reLaunch({
  137. url:'/pages/index/category'
  138. })
  139. }
  140. })
  141. // uni.reLaunch({
  142. // url:'/pages/index/category'
  143. // })
  144. })
  145. },
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .login {
  151. display: flex;
  152. flex-direction: column;
  153. justify-content: center;
  154. align-items: center;
  155. height: 90vh;
  156. .app-name{
  157. font-size: 40rpx;
  158. color: black;
  159. font-weight: 500;
  160. margin-bottom: 20rpx;
  161. }
  162. .logo{
  163. height: 300rpx;
  164. width: 300rpx;
  165. image{
  166. height: 300rpx;
  167. width: 300rpx;
  168. border-radius: 50%;
  169. }
  170. margin: 30rpx 0;
  171. }
  172. .title {
  173. line-height: 45rpx;
  174. // font-weight: 900;
  175. }
  176. .line {
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. width: 80%;
  181. border-bottom: 2rpx solid #00000020;
  182. padding: 25rpx 0;
  183. margin: 0 auto;
  184. }
  185. .reset-button {
  186. width: 100%;
  187. padding: 0;
  188. margin: 0;
  189. margin-top: 6vh;
  190. // background-color: transparent;
  191. // padding: 0;
  192. margin: 0;
  193. line-height: normal;
  194. font-size: inherit;
  195. color: inherit;
  196. }
  197. /* 去除按钮边框 */
  198. .reset-button::after {
  199. border: none;
  200. }
  201. .btn {
  202. // background: $uni-linear-gradient-btn-color;
  203. background: $uni-color;
  204. color: #fff;
  205. width: 76%;
  206. padding: 30rpx 0;
  207. text-align: center;
  208. border-radius: 50rpx;
  209. margin-top: 10vh;
  210. }
  211. .getPhoneNumber{
  212. // all: unset;
  213. display: flex;
  214. justify-content: center;
  215. align-items: center;
  216. // background: $uni-linear-gradient-btn-color;
  217. background: $uni-color;
  218. color: #fff;
  219. width: 200rpx;
  220. height: 90rpx;
  221. border-radius: 45rpx;
  222. font-size: 24rpx;
  223. }
  224. }
  225. </style>