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

299 lines
5.9 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 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. <!-- #ifdef MP-WEIXIN -->
  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. <!-- #endif -->
  63. <!-- #ifdef H5 -->
  64. <view class="content">
  65. <input
  66. placeholder-class="uni-placeholder"
  67. placeholder="请输入手机号"
  68. style="text-align: right;"
  69. v-model="userInfoForm.phone"
  70. />
  71. </view>
  72. <!-- #endif -->
  73. </view>
  74. </view>
  75. <view class="btn" @click="submit">
  76. 确认
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. data() {
  83. return {
  84. userInfoForm: {
  85. headImage: '',
  86. nickName: '',
  87. phone: '',
  88. }
  89. };
  90. },
  91. onShow() {},
  92. onLoad() {
  93. this.userInfoForm.nickName = this.userInfo.nickName || ''
  94. this.userInfoForm.headImage = this.userInfo.headImage || ''
  95. },
  96. computed: {},
  97. methods: {
  98. onChooseAvatar(res) {
  99. this.$Oss.ossUpload(res.target.avatarUrl)
  100. .then(url => {
  101. this.userInfoForm.headImage = url
  102. })
  103. },
  104. getPhone(e){
  105. this.$api('bindPhone', {
  106. phoneCode : e.detail.code
  107. }, res => {
  108. if(res.code == 200){
  109. let phoneObj = JSON.parse(res.result)
  110. if(phoneObj.errmsg == 'ok'){
  111. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  112. }else{
  113. uni.showModal({
  114. title: phoneObj.errmsg
  115. })
  116. }
  117. }
  118. })
  119. },
  120. submit() {
  121. let self = this
  122. uni.createSelectorQuery().in(this)
  123. .select("#nickName")
  124. .fields({
  125. properties: ["value"],
  126. })
  127. .exec((res) => {
  128. const nickName = res?.[0]?.value
  129. self.userInfoForm.nickName = nickName
  130. if (self.$utils.verificationAll(self.userInfoForm, {
  131. headImage: '请选择头像',
  132. nickName: '请填写昵称',
  133. phone: '请填写手机号',
  134. })) {
  135. return
  136. }
  137. self.$api('updateInfo', {
  138. headImage : self.userInfoForm.headImage,
  139. nickName : self.userInfoForm.nickName,
  140. phone : self.userInfoForm.phone,
  141. }, res => {
  142. if (res.code == 200) {
  143. uni.reLaunch({
  144. url:'/pages/index/index'
  145. })
  146. }
  147. })
  148. })
  149. },
  150. }
  151. }
  152. </script>
  153. <style lang="scss" scoped>
  154. .login {
  155. display: flex;
  156. justify-content: flex-start;
  157. align-items: center;
  158. height: 100vh;
  159. flex-direction: column;
  160. position: relative;
  161. background: $uni-fg-color;
  162. .logo{
  163. margin-top: 334rpx;
  164. width: 320rpx;
  165. image{
  166. height: 150rpx;
  167. width: 320rpx;
  168. }
  169. .text{
  170. margin-top: 90rpx;
  171. font-size: 38rpx;
  172. font-family: PingFang SC, PingFang SC-Bold;
  173. font-weight: 700;
  174. text-align: center;
  175. color: #000000;
  176. }
  177. }
  178. .title {
  179. margin-top: 48rpx;
  180. font-size: 32rpx;
  181. font-family: PingFang SC, PingFang SC-Regular;
  182. font-weight: 400;
  183. color: #000000;
  184. }
  185. .form {
  186. margin-top: 45rpx;
  187. width: 100%;
  188. display: flex;
  189. flex-direction: column;
  190. align-items: center;
  191. .form-item {
  192. width: 85%;
  193. display: flex;
  194. align-items: baseline;
  195. padding: 11rpx 23rpx;
  196. position: relative;
  197. &::after {
  198. position: absolute;
  199. bottom: 0;
  200. left: 0;
  201. content: " ";
  202. width: 100%;
  203. height: 1rpx;
  204. border-top: 1px solid rgba(112, 112, 112, 0.35);
  205. transform: scaleY(.5);
  206. }
  207. .label {
  208. width: 90rpx;
  209. font-size: 30rpx;
  210. font-family: SimSun, SimSun-Regular;
  211. font-weight: 400;
  212. text-align: left;
  213. color: #000000;
  214. }
  215. .content {
  216. flex: 1;
  217. text-align: right;
  218. }
  219. }
  220. .form-item + .form-item {
  221. margin-top: 50rpx;
  222. }
  223. .btn-avatar {
  224. background: transparent;
  225. border: none;
  226. border-radius: none;
  227. box-shadow: none;
  228. padding: 0;
  229. margin: 0;
  230. font-size: 0;
  231. text-align: right;
  232. }
  233. .avatar {
  234. display: inline-block;
  235. width: 70rpx;
  236. height: 70rpx;
  237. margin-right: 63rpx;
  238. }
  239. .btn-phone {
  240. border: none;
  241. border-radius: 0;
  242. padding: 7rpx;
  243. margin: 0;
  244. text-align: right;
  245. color: #C7C7C7;
  246. font-size: 30rpx;
  247. line-height: 1;
  248. }
  249. }
  250. .btn {
  251. text-align: center;
  252. margin-top: 155rpx;
  253. width: 80%;
  254. height: 100rpx;
  255. border-radius: 50rpx;
  256. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  257. color: #fff;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. border-radius: 50rpx;
  262. border: none;
  263. }
  264. }
  265. </style>