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

242 lines
5.1 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 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_app_name">
  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. uni.reLaunch({
  136. url:'/pages/index/category'
  137. })
  138. }
  139. })
  140. // uni.reLaunch({
  141. // url:'/pages/index/category'
  142. // })
  143. })
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .login {
  150. display: flex;
  151. flex-direction: column;
  152. justify-content: center;
  153. align-items: center;
  154. height: 90vh;
  155. .app-name{
  156. font-size: 40rpx;
  157. color: black;
  158. font-weight: 500;
  159. margin-bottom: 20rpx;
  160. }
  161. .logo{
  162. height: 300rpx;
  163. width: 300rpx;
  164. image{
  165. height: 300rpx;
  166. width: 300rpx;
  167. border-radius: 50%;
  168. }
  169. margin: 30rpx 0;
  170. }
  171. .title {
  172. line-height: 45rpx;
  173. // font-weight: 900;
  174. }
  175. .line {
  176. display: flex;
  177. justify-content: space-between;
  178. align-items: center;
  179. width: 80%;
  180. border-bottom: 2rpx solid #00000020;
  181. padding: 25rpx 0;
  182. margin: 0 auto;
  183. }
  184. .reset-button {
  185. width: 100%;
  186. padding: 0;
  187. margin: 0;
  188. margin-top: 6vh;
  189. // background-color: transparent;
  190. // padding: 0;
  191. margin: 0;
  192. line-height: normal;
  193. font-size: inherit;
  194. color: inherit;
  195. }
  196. /* 去除按钮边框 */
  197. .reset-button::after {
  198. border: none;
  199. }
  200. .btn {
  201. // background: $uni-linear-gradient-btn-color;
  202. background: $uni-color;
  203. color: #fff;
  204. width: 76%;
  205. padding: 30rpx 0;
  206. text-align: center;
  207. border-radius: 50rpx;
  208. margin-top: 10vh;
  209. }
  210. .getPhoneNumber{
  211. // all: unset;
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. // background: $uni-linear-gradient-btn-color;
  216. background: $uni-color;
  217. color: #fff;
  218. width: 200rpx;
  219. height: 90rpx;
  220. border-radius: 45rpx;
  221. font-size: 24rpx;
  222. }
  223. }
  224. </style>