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

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