裂变星小程序-25.03.04
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.

316 lines
5.9 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="page flex flex-column">
  3. <image class="logo" :src="configList.logo_image" mode=""></image>
  4. <view class="title">
  5. {{ configList.logo_name }}
  6. </view>
  7. <view class="desc">
  8. 申请获取你的头像昵称
  9. </view>
  10. <view class="form">
  11. <view class="form-item">
  12. <view class="label">
  13. 头像
  14. </view>
  15. <view class="content">
  16. <button class="btn-avatar" :plain="true" :hairline="false" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  17. <image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" class="avatar"
  18. mode=""></image>
  19. <image src="../static/auth/avatar.png" v-else class="avatar"
  20. mode=""></image>
  21. </button>
  22. </view>
  23. </view>
  24. <view class="form-item">
  25. <view class="label">
  26. 昵称
  27. </view>
  28. <view class="content">
  29. <input
  30. id="nickName"
  31. type="nickname"
  32. placeholder="请输入昵称"
  33. style="text-align: right;"
  34. placeholder-class="auth-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
  45. id="wxCode"
  46. type="wxCode"
  47. placeholder="请输入微信号"
  48. style="text-align: right;"
  49. placeholder-class="auth-placeholder"
  50. v-model="userInfoForm.wxCode"
  51. />
  52. </view>
  53. </view>
  54. </view>
  55. <button
  56. :plain="true" :hairline="false"
  57. class="btn"
  58. open-type="getPhoneNumber"
  59. @getphonenumber="getPhone"
  60. >
  61. 获取电话号码
  62. </button>
  63. <button
  64. :plain="true" :hairline="false"
  65. class="btn btn-confirm"
  66. @click="submit"
  67. >
  68. 确认
  69. </button>
  70. </view>
  71. </template>
  72. <script>
  73. import { mapState } from 'vuex'
  74. export default {
  75. data() {
  76. return {
  77. userInfoForm: {
  78. headImage: '',
  79. nickName: '',
  80. phone : '',
  81. wxCode : '',
  82. },
  83. mode: 'add',
  84. };
  85. },
  86. computed: {
  87. ...mapState(['configList'])
  88. },
  89. onShow() {},
  90. onLoad(option) {
  91. const { mode } = option || {}
  92. this.userInfoForm.phone = this.userInfo.phone || ''
  93. this.userInfoForm.nickName = this.userInfo.nickName || ''
  94. this.userInfoForm.headImage = this.userInfo.headImage || ''
  95. this.userInfoForm.wxCode = this.userInfo.wxCode || ''
  96. this.mode = mode
  97. },
  98. computed: {},
  99. methods: {
  100. onChooseAvatar(res) {
  101. this.$Oss.ossUpload(res.target.avatarUrl)
  102. .then(url => {
  103. this.userInfoForm.headImage = url
  104. })
  105. },
  106. getPhone(e){
  107. this.$api('bindPhone', {
  108. code : e.detail.code
  109. }, res => {
  110. if(res.code == 200){
  111. let phoneObj = JSON.parse(res.result)
  112. if(phoneObj.errmsg == 'ok'){
  113. this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
  114. }else{
  115. uni.showModal({
  116. title: phoneObj.errmsg
  117. })
  118. }
  119. console.log(phoneObj);
  120. }
  121. })
  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. wxCode: '请填写微信号',
  137. })) {
  138. return
  139. }
  140. self.$api('updateInfo', {
  141. headImage : self.userInfoForm.headImage,
  142. nickName : self.userInfoForm.nickName,
  143. phone : self.userInfoForm.phone,
  144. wxCode : self.userInfoForm.wxCode,
  145. }, res => {
  146. if (res.code == 200) {
  147. if (this.mode === 'edit') {
  148. uni.showToast({
  149. title: '提交成功',
  150. icon: 'none'
  151. })
  152. setTimeout(uni.navigateBack, 1000, -1)
  153. return
  154. }
  155. uni.navigateBack({
  156. delta: 2,
  157. fail: () => {
  158. uni.reLaunch({
  159. url: '/pages/index/index'
  160. })
  161. }
  162. });
  163. }
  164. })
  165. })
  166. },
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .page {
  172. background-color: $uni-fg-color;
  173. position: relative;
  174. width: 100vw;
  175. height: 100vh;
  176. padding-top: calc(#{$navbar-height} + var(--status-bar-height) + 20rpx);
  177. padding-left: 60rpx;
  178. padding-right: 60rpx;
  179. box-sizing: border-box;
  180. justify-content: flex-start;
  181. }
  182. .logo {
  183. width: 148rpx;
  184. height: 148rpx;
  185. margin-top: 96rpx;
  186. }
  187. .title {
  188. color: #333333;
  189. font-size: 32rpx;
  190. font-weight: 900;
  191. margin-top: 20rpx;
  192. }
  193. .desc {
  194. color: #474747;
  195. font-size: 28rpx;
  196. margin-top: 40rpx;
  197. }
  198. .form {
  199. margin-top: 120rpx;
  200. margin-bottom: 193rpx;
  201. width: 100%;
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. box-sizing: border-box;
  206. .form-item {
  207. width: 100%;
  208. min-height: 136rpx;
  209. border-bottom: 1rpx solid #E8E8E8;
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. &:first-child {
  214. border-top: 1rpx solid #E8E8E8;
  215. }
  216. .label {
  217. width: 110rpx;
  218. font-size: 36rpx;
  219. font-weight: 500;
  220. text-align: left;
  221. color: #474747;
  222. }
  223. .content {
  224. flex: 1;
  225. text-align: right;
  226. }
  227. }
  228. .btn-avatar {
  229. background: transparent;
  230. border: none;
  231. border-radius: none;
  232. box-shadow: none;
  233. padding: 0;
  234. margin: 0;
  235. font-size: 0;
  236. text-align: right;
  237. }
  238. .avatar {
  239. display: inline-block;
  240. width: 96rpx;
  241. height: 96rpx;
  242. }
  243. .btn-phone {
  244. border: none;
  245. border-radius: 0;
  246. padding: 7rpx;
  247. margin: 0;
  248. text-align: right;
  249. color: #7C7C7C;
  250. font-size: 26rpx;
  251. line-height: 1;
  252. }
  253. }
  254. .auth-placeholder {
  255. color: #7C7C7C;
  256. font-size: 26rpx;
  257. }
  258. .btn {
  259. width: 100%;
  260. height: auto;
  261. border-radius: 45rpx;
  262. color: #07C160;
  263. border-color: #07C160;
  264. padding: 25rpx 0;
  265. box-sizing: border-box;
  266. font-size: 28rpx;
  267. line-height: 1;
  268. margin: 0;
  269. &-confirm {
  270. background-color: #07C160;
  271. color: #FFFFFF;
  272. }
  273. & + & {
  274. margin-top: 34rpx;
  275. }
  276. }
  277. </style>