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

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