推拿小程序前端代码仓库
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.

286 lines
5.6 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="login">
  3. <view class="logo">
  4. <!-- 后续改回接口获取 -->
  5. <image src="../static/auth/logo.png" mode=""></image>
  6. <view class="text">
  7. {{ configList.logo_name }}
  8. </view>
  9. </view>
  10. <view class="title">
  11. 申请获取你的头像昵称
  12. </view>
  13. <view class="form">
  14. <view class="form-item">
  15. <view class="label">
  16. 头像
  17. </view>
  18. <view class="content">
  19. <button class="btn-avatar" :plain="true" :hairline="false" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  20. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" class="avatar"
  21. mode=""></image>
  22. <view v-else class="avatar" style="background-color: #C7C7C7; border-radius: 50%;">
  23. <uv-icon name="account-fill" color="#ffffff" size="70rpx"></uv-icon>
  24. </view>
  25. </button>
  26. </view>
  27. </view>
  28. <view class="form-item">
  29. <view class="label">
  30. 昵称
  31. </view>
  32. <view class="content">
  33. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  34. placeholder-class="uni-placeholder"
  35. v-model="userInfoForm.nickName"
  36. />
  37. </view>
  38. </view>
  39. <view class="form-item">
  40. <view class="label">
  41. 手机号
  42. </view>
  43. <view class="content">
  44. <input v-if="userInfoForm.phone"
  45. placeholder-class="uni-placeholder"
  46. placeholder="请输入手机号"
  47. style="text-align: right;"
  48. disabled
  49. v-model="userInfoForm.phone"
  50. />
  51. <view v-else>
  52. <button
  53. :plain="true" :hairline="false"
  54. class="btn-phone"
  55. open-type="getPhoneNumber"
  56. @getphonenumber="getPhone"
  57. >
  58. 获取电话号码
  59. </button>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="btn" @click="submit">
  65. 确认
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. userInfoForm: {
  74. headImage: '',
  75. nickName: '',
  76. phone : '',
  77. }
  78. };
  79. },
  80. onShow() {},
  81. onLoad() {
  82. this.userInfoForm.phone = this.userInfo.phone || ''
  83. this.userInfoForm.nickName = this.userInfo.nickName || ''
  84. this.userInfoForm.headImage = this.userInfo.headImage || ''
  85. },
  86. computed: {},
  87. methods: {
  88. onChooseAvatar(res) {
  89. this.$Oss.ossUpload(res.target.avatarUrl)
  90. .then(url => {
  91. this.userInfoForm.headImage = url
  92. })
  93. },
  94. getPhone(e){
  95. this.$api('bindPhone', {
  96. phoneCode : e.detail.code
  97. }, res => {
  98. if(res.code == 200){
  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. self.$api('updateInfo', {
  129. avatarUrl : self.userInfoForm.headImage,
  130. nickName : self.userInfoForm.nickName,
  131. phone : self.userInfoForm.phone,
  132. }, res => {
  133. if (res.code == 200) {
  134. uni.reLaunch({
  135. url:'/pages/index/index'
  136. })
  137. }
  138. })
  139. })
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .login {
  146. display: flex;
  147. justify-content: flex-start;
  148. align-items: center;
  149. height: 100vh;
  150. flex-direction: column;
  151. position: relative;
  152. background: $uni-bg-color;
  153. .logo{
  154. margin-top: 334rpx;
  155. width: 320rpx;
  156. image{
  157. height: 150rpx;
  158. width: 320rpx;
  159. }
  160. .text{
  161. margin-top: 90rpx;
  162. font-size: 38rpx;
  163. font-family: PingFang SC, PingFang SC-Bold;
  164. font-weight: 700;
  165. text-align: center;
  166. color: #000000;
  167. }
  168. }
  169. .title {
  170. margin-top: 48rpx;
  171. font-size: 32rpx;
  172. font-family: PingFang SC, PingFang SC-Regular;
  173. font-weight: 400;
  174. color: #000000;
  175. }
  176. .form {
  177. margin-top: 45rpx;
  178. width: 100%;
  179. display: flex;
  180. flex-direction: column;
  181. align-items: center;
  182. .form-item {
  183. width: 85%;
  184. display: flex;
  185. align-items: baseline;
  186. padding: 11rpx 23rpx;
  187. position: relative;
  188. &::after {
  189. position: absolute;
  190. bottom: 0;
  191. left: 0;
  192. content: " ";
  193. width: 100%;
  194. height: 1rpx;
  195. border-top: 1px solid rgba(112, 112, 112, 0.35);
  196. transform: scaleY(.5);
  197. }
  198. .label {
  199. width: 90rpx;
  200. font-size: 30rpx;
  201. font-family: SimSun, SimSun-Regular;
  202. font-weight: 400;
  203. text-align: left;
  204. color: #000000;
  205. }
  206. .content {
  207. flex: 1;
  208. text-align: right;
  209. }
  210. }
  211. .form-item + .form-item {
  212. margin-top: 50rpx;
  213. }
  214. .btn-avatar {
  215. background: transparent;
  216. border: none;
  217. border-radius: none;
  218. box-shadow: none;
  219. padding: 0;
  220. margin: 0;
  221. font-size: 0;
  222. text-align: right;
  223. }
  224. .avatar {
  225. display: inline-block;
  226. width: 70rpx;
  227. height: 70rpx;
  228. margin-right: 63rpx;
  229. }
  230. .btn-phone {
  231. border: none;
  232. border-radius: 0;
  233. padding: 7rpx;
  234. margin: 0;
  235. text-align: right;
  236. color: #C7C7C7;
  237. font-size: 30rpx;
  238. line-height: 1;
  239. }
  240. }
  241. .btn {
  242. text-align: center;
  243. margin-top: 155rpx;
  244. width: 80%;
  245. height: 100rpx;
  246. border-radius: 50rpx;
  247. background-color: #B3997E;
  248. color: #fff;
  249. display: flex;
  250. justify-content: center;
  251. align-items: center;
  252. border-radius: 50rpx;
  253. border: none;
  254. }
  255. }
  256. </style>