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

247 lines
5.7 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
4 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
3 months ago
5 months ago
3 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 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
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. {{$t('pages_login.wxUserInfo.requestInfo')}}
  11. </view>
  12. <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  13. <view class="line">
  14. <view class="">
  15. {{$t('pages_login.wxUserInfo.avatar')}}
  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. {{$t('pages_login.wxUserInfo.nickname')}}
  27. </view>
  28. <view class="">
  29. <input type="nickname" :placeholder="$t('pages_login.wxUserInfo.enterNickname')" style="text-align: right;" id="nickName"
  30. v-model="userInfoForm.nickName" />
  31. </view>
  32. </view>
  33. <view class="line">
  34. <view class="">
  35. {{$t('pages_login.wxUserInfo.gender')}}
  36. </view>
  37. <view class="">
  38. <input
  39. :placeholder="$t('pages_login.wxUserInfo.selectGender')"
  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. {{$t('pages_login.wxUserInfo.phone')}}
  49. </view>
  50. <view class=""
  51. v-if="userInfoForm.phone">
  52. <input :placeholder="$t('pages_login.wxUserInfo.enterPhone')" 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. {{$t('pages_login.wxUserInfo.getPhone')}}
  63. </button>
  64. </view>
  65. </view>
  66. <uv-picker ref="sexPicker" :columns="sexcolumns" @confirm="sexConfirm"></uv-picker>
  67. <view class="btn" @click="submit">
  68. {{$t('pages_login.wxUserInfo.confirm')}}
  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. [this.$t('pages_login.wxUserInfo.male'), this.$t('pages_login.wxUserInfo.female')]
  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. this.getUserInfo()
  93. },
  94. computed: {},
  95. methods: {
  96. getUserInfo(){
  97. this.$api('getInfo', res => {
  98. if(res.code == 200){
  99. this.userInfoForm.phone = res.result.phone || ''
  100. this.userInfoForm.nickName = res.result.nickName || ''
  101. this.userInfoForm.headImage = res.result.headImage || ''
  102. this.userInfoForm.sex = res.result.sex || ''
  103. }
  104. })
  105. },
  106. onChooseAvatar(res) {
  107. let self = this
  108. self.$Oss.ossUpload(res.target.avatarUrl)
  109. .then(url => {
  110. self.userInfoForm.headImage = url
  111. })
  112. },
  113. getPhone(e){
  114. console.log(e,'e')
  115. this.$api('bindPhone', {
  116. phoneCode : e.detail.code
  117. }, res => {
  118. if(res.code == 200){
  119. let phoneObj = JSON.parse(res.result)
  120. if(phoneObj.errmsg == 'ok'){
  121. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  122. }else{
  123. uni.showModal({
  124. title: phoneObj.errmsg
  125. })
  126. }
  127. console.log(phoneObj);
  128. }
  129. })
  130. },
  131. sexConfirm(val) {
  132. this.userInfoForm.sex = val.value[0]
  133. },
  134. submit() {
  135. let self = this
  136. uni.createSelectorQuery().in(this)
  137. .select("#nickName")
  138. .fields({
  139. properties: ["value"],
  140. })
  141. .exec((res) => {
  142. const nickName = res?.[0]?.value
  143. self.userInfoForm.nickName = nickName
  144. if (self.$utils.verificationAll(self.userInfoForm, {
  145. headImage: self.$t('pages_login.wxUserInfo.pleaseSelectAvatar'),
  146. nickName: self.$t('pages_login.wxUserInfo.pleaseEnterNickname'),
  147. phone: self.$t('pages_login.wxUserInfo.pleaseEnterPhone'),
  148. sex: self.$t('pages_login.wxUserInfo.pleaseSelectGender'),
  149. })) {
  150. return
  151. }
  152. self.$api('updateInfo', {
  153. headImage : self.userInfoForm.headImage,
  154. nickName : self.userInfoForm.nickName,
  155. phone : self.userInfoForm.phone,
  156. sex : self.userInfoForm.sex,
  157. }, res => {
  158. if (res.code == 200) {
  159. this.$store.commit('getUserInfo')
  160. uni.reLaunch({
  161. url:'/pages/index/index'
  162. })
  163. }
  164. })
  165. })
  166. },
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .login {
  172. display: flex;
  173. flex-direction: column;
  174. justify-content: center;
  175. align-items: center;
  176. height: 100vh;
  177. background-color: #fff;
  178. .logo{
  179. height: 140rpx;
  180. width: 140rpx;
  181. image{
  182. height: 140rpx;
  183. width: 140rpx;
  184. border-radius: 30rpx;
  185. }
  186. margin-bottom: 20rpx;
  187. }
  188. .title {
  189. line-height: 56rpx;
  190. font-weight: 900;
  191. font-size: 40rpx;
  192. }
  193. .line {
  194. display: flex;
  195. justify-content: space-between;
  196. align-items: center;
  197. width: 80%;
  198. border-bottom: 1px solid #00000023;
  199. padding: 30rpx 0;
  200. margin: 0 auto;
  201. font-size: 30rpx;
  202. }
  203. .chooseAvatar {
  204. width: 100%;
  205. padding: 0;
  206. margin: 0;
  207. margin-top: 10vh;
  208. border: none;
  209. }
  210. .btn {
  211. background: $uni--bg-color-btn;
  212. color: #fff;
  213. width: 80%;
  214. padding: 20rpx 0;
  215. text-align: center;
  216. border-radius: 15rpx;
  217. margin-top: 10vh;
  218. }
  219. .getPhoneNumber{
  220. display: flex;
  221. justify-content: center;
  222. align-items: center;
  223. background: $uni--bg-color-btn;
  224. color: #fff;
  225. width: 240rpx;
  226. height: 60rpx;
  227. border-radius: 30rpx;
  228. font-size: 26rpx;
  229. flex-shrink: 0;
  230. }
  231. }
  232. </style>