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

237 lines
4.9 KiB

5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
5 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
3 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="title">
  7. {{ configList.logo_name }}
  8. </view>
  9. <view class="title">
  10. 申请获取你的头像昵称
  11. </view>
  12. <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  13. <view class="line">
  14. <view class="">
  15. 头像
  16. </view>
  17. <view class="">
  18. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" style="width: 60rpx;height: 60rpx;"
  19. mode=""></image>
  20. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode=""></image>
  21. </view>
  22. </view>
  23. </button>
  24. <view class="line">
  25. <view class="">
  26. 昵称
  27. </view>
  28. <view class="">
  29. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  30. v-model="userInfoForm.nickName" />
  31. </view>
  32. </view>
  33. <view class="line">
  34. <view class="">
  35. 性别
  36. </view>
  37. <view class="">
  38. <input
  39. placeholder="请选择性别"
  40. disabled
  41. @click="$refs.sexPicker.open()"
  42. style="text-align: right;"
  43. v-model="userInfoForm.sex" />
  44. </view>
  45. </view>
  46. <view class="line">
  47. <view class="">
  48. 手机号
  49. </view>
  50. <view class=""
  51. v-if="userInfoForm.phone">
  52. <input placeholder="请输入手机号" style="text-align: right;"
  53. disabled
  54. v-model="userInfoForm.phone" />
  55. </view>
  56. <view class=""
  57. v-else>
  58. <button
  59. class="getPhoneNumber"
  60. open-type="getPhoneNumber"
  61. @getphonenumber="getPhone">
  62. 获取电话号码
  63. </button>
  64. </view>
  65. </view>
  66. <uv-picker ref="sexPicker" :columns="sexcolumns" @confirm="sexConfirm"></uv-picker>
  67. <view class="btn" @click="submit">
  68. 确认
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. userInfoForm: {
  77. headImage: '',
  78. nickName: '',
  79. phone : '',
  80. sex : '',
  81. },
  82. sexcolumns:[
  83. ['男','女']
  84. ],
  85. };
  86. },
  87. onShow() {},
  88. onLoad() {
  89. this.userInfoForm.phone = this.userInfo.phone || ''
  90. this.userInfoForm.nickName = this.userInfo.nickName || ''
  91. this.userInfoForm.headImage = this.userInfo.headImage || ''
  92. },
  93. computed: {},
  94. methods: {
  95. onChooseAvatar(res) {
  96. let self = this
  97. self.$Oss.ossUpload(res.target.avatarUrl)
  98. .then(url => {
  99. self.userInfoForm.headImage = url
  100. })
  101. },
  102. getPhone(e){
  103. console.log(e,'e')
  104. this.$api('bindPhone', {
  105. phoneCode : e.detail.code
  106. }, res => {
  107. if(res.code == 200){
  108. let phoneObj = JSON.parse(res.result)
  109. if(phoneObj.errmsg == 'ok'){
  110. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  111. }else{
  112. uni.showModal({
  113. title: phoneObj.errmsg
  114. })
  115. }
  116. console.log(phoneObj);
  117. }
  118. })
  119. },
  120. sexConfirm(val) {
  121. this.userInfoForm.sex = val.value[0]
  122. },
  123. submit() {
  124. let self = this
  125. uni.createSelectorQuery().in(this)
  126. .select("#nickName")
  127. .fields({
  128. properties: ["value"],
  129. })
  130. .exec((res) => {
  131. const nickName = res?.[0]?.value
  132. self.userInfoForm.nickName = nickName
  133. if (self.$utils.verificationAll(self.userInfoForm, {
  134. headImage: '请选择头像',
  135. nickName: '请填写昵称',
  136. phone: '请填写昵称',
  137. sex: '请选择性别',
  138. })) {
  139. return
  140. }
  141. self.$api('updateInfo', {
  142. headImage : self.userInfoForm.headImage,
  143. nickName : self.userInfoForm.nickName,
  144. phone : self.userInfoForm.phone,
  145. sex : self.userInfoForm.sex,
  146. }, res => {
  147. if (res.code == 200) {
  148. this.$store.commit('getUserInfo')
  149. uni.reLaunch({
  150. url:'/pages/index/index'
  151. })
  152. }
  153. })
  154. })
  155. },
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .login {
  161. display: flex;
  162. flex-direction: column;
  163. justify-content: center;
  164. align-items: center;
  165. height: 100vh;
  166. background-color: #fff;
  167. .logo{
  168. height: 140rpx;
  169. width: 140rpx;
  170. image{
  171. height: 140rpx;
  172. width: 140rpx;
  173. border-radius: 30rpx;
  174. }
  175. margin-bottom: 20rpx;
  176. }
  177. .title {
  178. line-height: 56rpx;
  179. font-weight: 900;
  180. font-size: 40rpx;
  181. }
  182. .line {
  183. display: flex;
  184. justify-content: space-between;
  185. align-items: center;
  186. width: 80%;
  187. border-bottom: 1px solid #00000023;
  188. padding: 30rpx 0;
  189. margin: 0 auto;
  190. font-size: 30rpx;
  191. }
  192. .chooseAvatar {
  193. width: 100%;
  194. padding: 0;
  195. margin: 0;
  196. margin-top: 10vh;
  197. border: none;
  198. }
  199. .btn {
  200. // background: $uni--bg-color-btn;
  201. background: #05C160;
  202. color: #fff;
  203. width: 80%;
  204. padding: 20rpx 0;
  205. text-align: center;
  206. border-radius: 45rpx;
  207. margin-top: 10vh;
  208. }
  209. .getPhoneNumber{
  210. display: flex;
  211. justify-content: center;
  212. align-items: center;
  213. // background: $uni--bg-color-btn;
  214. background: #05C160;
  215. color: #fff;
  216. width: 220rpx;
  217. height: 60rpx;
  218. border-radius: 30rpx;
  219. font-size: 28rpx;
  220. }
  221. }
  222. </style>