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

231 lines
4.8 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
5 months ago
7 months ago
5 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="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. if(phoneObj.errmsg == 'ok'){
  96. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  97. }else{
  98. uni.showModal({
  99. title: phoneObj.errmsg
  100. })
  101. }
  102. console.log(phoneObj);
  103. }
  104. })
  105. },
  106. submit() {
  107. let self = this
  108. uni.createSelectorQuery().in(this)
  109. .select("#nickName")
  110. .fields({
  111. properties: ["value"],
  112. })
  113. .exec((res) => {
  114. const nickName = res?.[0]?.value
  115. self.userInfoForm.nickName = nickName
  116. if (self.$utils.verificationAll(self.userInfoForm, {
  117. headImage: '请选择头像',
  118. nickName: '请填写昵称',
  119. phone: '请填写手机号',
  120. })) {
  121. return
  122. }
  123. self.$api('updateInfo', {
  124. avatarUrl : self.userInfoForm.headImage,
  125. nickName : self.userInfoForm.nickName,
  126. phone : self.userInfoForm.phone,
  127. }, res => {
  128. if (res.code == 200) {
  129. uni.reLaunch({
  130. url:'/pages/index/index'
  131. })
  132. }
  133. })
  134. })
  135. },
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .login {
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. height: 90vh;
  146. .app-name{
  147. font-size: 40rpx;
  148. color: black;
  149. font-weight: 500;
  150. margin-bottom: 20rpx;
  151. }
  152. .logo{
  153. height: 300rpx;
  154. width: 300rpx;
  155. image{
  156. height: 300rpx;
  157. width: 300rpx;
  158. border-radius: 50%;
  159. }
  160. margin: 30rpx 0;
  161. }
  162. .title {
  163. line-height: 45rpx;
  164. // font-weight: 900;
  165. }
  166. .line {
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. width: 80%;
  171. border-bottom: 2rpx solid #00000020;
  172. padding: 25rpx 0;
  173. margin: 0 auto;
  174. }
  175. .reset-button {
  176. width: 100%;
  177. padding: 0;
  178. margin: 0;
  179. margin-top: 6vh;
  180. // background-color: transparent;
  181. // padding: 0;
  182. margin: 0;
  183. line-height: normal;
  184. font-size: inherit;
  185. color: inherit;
  186. }
  187. /* 去除按钮边框 */
  188. .reset-button::after {
  189. border: none;
  190. }
  191. .btn {
  192. // background: $uni-linear-gradient-btn-color;
  193. background: $uni-color;
  194. color: #fff;
  195. width: 76%;
  196. padding: 30rpx 0;
  197. text-align: center;
  198. border-radius: 50rpx;
  199. margin-top: 10vh;
  200. }
  201. .getPhoneNumber{
  202. // all: unset;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. // background: $uni-linear-gradient-btn-color;
  207. background: $uni-color;
  208. color: #fff;
  209. width: 200rpx;
  210. height: 90rpx;
  211. border-radius: 45rpx;
  212. font-size: 24rpx;
  213. }
  214. }
  215. </style>