瑶都万能墙
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.

441 lines
9.3 KiB

8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
  1. <template>
  2. <view class="login">
  3. <!-- <view class="title">
  4. 瑶都万能墙
  5. </view>
  6. <view class="title">
  7. 申请获取你的头像昵称
  8. </view> -->
  9. <!-- <button class="chooseAvatar" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  10. <view class="line">
  11. <view class="">
  12. 头像
  13. </view>
  14. <view class="">
  15. <image :src="form.headImage" v-if="form.headImage" style="width: 60rpx;height: 60rpx;"
  16. mode=""></image>
  17. <image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode=""></image>
  18. </view>
  19. </view>
  20. </button>
  21. <view class="line">
  22. <view class="">
  23. 昵称
  24. </view>
  25. <view class="">
  26. <input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
  27. v-model="form.nickName" />
  28. </view>
  29. </view> -->
  30. <view class="bg1"></view>
  31. <view class="title">
  32. 定制自己的形象
  33. </view>
  34. <view
  35. v-if="back"
  36. @click="$utils.navigateBack"
  37. style="position: absolute;top: 120rpx;left: 20rpx;">
  38. <uv-icon
  39. size="30rpx"
  40. color="#000"
  41. name="arrow-left"></uv-icon>
  42. </view>
  43. <button class="chooseAvatar"
  44. open-type="chooseAvatar"
  45. @chooseavatar="onChooseAvatar">
  46. <image :src="form.headImage"
  47. mode="aspectFill"></image>
  48. </button>
  49. <input type="nickname"
  50. placeholder="给自己起一个响亮的名字"
  51. class="nickname" id="nickName"
  52. v-model="form.nickName" />
  53. <view class="sexSelect">
  54. <view
  55. @click="sexClick(item)"
  56. v-for="(item, index) in sexList"
  57. :key="index"
  58. :style="{color : form.sex == item.value ? item.actColor : '#333'}">
  59. <uv-icon
  60. size="30rpx"
  61. :color="form.sex == item.value ? item.actColor : '#333'"
  62. :name="item.icon"></uv-icon>
  63. {{ item.value }}
  64. </view>
  65. </view>
  66. <view class="address"
  67. @click="$refs.datetimePicker.open()">
  68. 您出生于{{ $dayjs(form.yearDate).format("YYYY") }}
  69. </view>
  70. <view class="address"
  71. @click="$refs.picker.open()">
  72. {{ form.address || '请选择居住地址'}}
  73. </view>
  74. <input type="text"
  75. placeholder="初中学校名字(选填)"
  76. class="school-input"
  77. v-model="form.czSchool" />
  78. <input type="text"
  79. placeholder="高中学校名字(选填)"
  80. class="school-input"
  81. v-model="form.gzSchool" />
  82. <view class="line">
  83. <view class="">
  84. 手机号
  85. </view>
  86. <view class=""
  87. v-if="form.phone">
  88. <input placeholder="请输入手机号" style="text-align: right;"
  89. disabled
  90. v-model="form.phone" />
  91. </view>
  92. <view class=""
  93. v-else>
  94. <button
  95. class="getPhoneNumber"
  96. open-type="getPhoneNumber"
  97. @getphonenumber="getPhone">
  98. 获取电话号码
  99. </button>
  100. </view>
  101. </view>
  102. <uv-datetime-picker
  103. ref="datetimePicker"
  104. v-model="form.yearDate"
  105. mode="year"
  106. :minDate="minDate"
  107. :maxDate="maxDate">
  108. </uv-datetime-picker>
  109. <uv-picker ref="picker"
  110. :columns="columns"
  111. keyName="name"
  112. @confirm="confirmAddress"></uv-picker>
  113. <view class="btn" @click="submit">
  114. 确认
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import { mapState } from 'vuex'
  120. import mixinsSex from '@/mixins/sex.js'
  121. export default {
  122. mixins : [mixinsSex],
  123. data() {
  124. return {
  125. form: {
  126. headImage: '',
  127. nickName: '',
  128. sex : '男',
  129. yearDate : this.$dayjs().add(-18, 'y').valueOf(),//默认满18岁
  130. address : '',
  131. phone : '',
  132. czSchool: '',
  133. gzSchool: '',
  134. },
  135. maxDate : this.$dayjs().valueOf(),
  136. minDate : this.$dayjs().add(-100, 'y').valueOf(),
  137. // sex : [
  138. // {
  139. // value : '男',
  140. // icon : 'man',
  141. // actColor : '#5baaff',
  142. // },
  143. // {
  144. // value : '女',
  145. // icon : 'woman',
  146. // actColor : '#ff50b3',
  147. // },
  148. // ],
  149. columns : [],
  150. back : '',
  151. };
  152. },
  153. computed: {
  154. ...mapState(['cityList', 'userInfo']),
  155. },
  156. onLoad({back}) {
  157. this.back = back
  158. // this.$nextTick(() => {
  159. // this.form.headImage = this.userInfo.headImage || this.form.headImage
  160. // this.form.nickName = this.userInfo.nickName || this.form.nickName
  161. // this.form.sex = this.userInfo.sex || this.form.sex
  162. // this.form.yearDate = this.userInfo.yearDate || this.form.yearDate
  163. // this.form.address = this.userInfo.address || this.form.address
  164. // })
  165. },
  166. onShow() {
  167. this.getCityList()
  168. this.getUserInfo()
  169. },
  170. computed: {},
  171. methods: {
  172. getPhone(e){
  173. this.$api('bindPhone', {
  174. phoneCode : e.detail.code
  175. }, res => {
  176. if(res.code == 200){
  177. let phoneObj = JSON.parse(res.result)
  178. if(phoneObj.errmsg == 'ok'){
  179. this.form.phone = phoneObj.phone_info.phoneNumber
  180. }else{
  181. uni.showModal({
  182. title: phoneObj.errmsg
  183. })
  184. }
  185. console.log(phoneObj);
  186. }
  187. })
  188. },
  189. onChooseAvatar(res) {
  190. let self = this
  191. self.$Oss.ossUpload(res.target.avatarUrl)
  192. .then(url => {
  193. self.form.headImage = url
  194. })
  195. },
  196. sexClick(item){
  197. this.form.sex = item.value
  198. },
  199. confirmAddress(e){
  200. this.form.address = e.value[0].name
  201. },
  202. // 获取城市
  203. getCityList(){
  204. this.$api('getCityList', res => {
  205. if(res.code == 200){
  206. this.columns = [
  207. res.result
  208. ]
  209. }
  210. })
  211. },
  212. getUserInfo(){
  213. this.$api('getInfo', res => {
  214. if(res.code == 200){
  215. this.form.headImage = res.result.headImage || this.form.headImage
  216. this.form.nickName = res.result.nickName || this.form.nickName
  217. this.form.sex = res.result.sex || this.form.sex
  218. this.form.phone = res.result.phone || this.form.phone
  219. this.form.yearDate = res.result.yearDate &&
  220. this.$dayjs(res.result.yearDate + '-01-01').valueOf() || this.form.yearDate
  221. this.form.address = res.result.address || this.form.address
  222. this.form.czSchool = res.result.czSchool || this.form.czSchool
  223. this.form.gzSchool = res.result.gzSchool || this.form.gzSchool
  224. }
  225. })
  226. },
  227. submit() {
  228. let self = this
  229. uni.createSelectorQuery().in(this)
  230. .select("#nickName")
  231. .fields({
  232. properties: ["value"],
  233. })
  234. .exec((res) => {
  235. const nickName = res?.[0]?.value
  236. self.form.nickName = nickName
  237. if (self.$utils.verificationAll(self.form, {
  238. headImage: '请选择头像',
  239. nickName: '请填写昵称',
  240. address: '请选择居住地址',
  241. phone: '请获取手机号',
  242. })) {
  243. return
  244. }
  245. let data = {
  246. ...self.form,
  247. yearDate : this.$dayjs(self.form.yearDate).format("YYYY")
  248. }
  249. self.$api('updateInfo', data, res => {
  250. if (res.code == 200) {
  251. uni.reLaunch({
  252. url:'/pages/index/index'
  253. })
  254. }
  255. })
  256. })
  257. },
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .login {
  263. display: flex;
  264. flex-direction: column;
  265. justify-content: center;
  266. align-items: center;
  267. height: 100vh;
  268. background-color: #fff;
  269. overflow: hidden;
  270. .bg1{
  271. width: 700rpx;
  272. height: 700rpx;
  273. border-radius: 50%;
  274. background-color: #ffc0b333;
  275. position: absolute;
  276. right: -300rpx;
  277. top: -300rpx;
  278. }
  279. .title {
  280. line-height: 45rpx;
  281. font-weight: 900;
  282. padding-bottom: 100rpx;
  283. font-size: 40rpx;
  284. }
  285. .chooseAvatar {
  286. width: 100%;
  287. padding: 0 !important;
  288. margin: 0 !important;
  289. border: none;
  290. background-color: #fff !important;
  291. width: 220rpx;
  292. height: 220rpx;
  293. border-radius: 50%;
  294. image{
  295. width: 200rpx;
  296. height: 200rpx;
  297. border-radius: 50%;
  298. box-shadow: 0 0 10rpx 10rpx #00000012;
  299. margin: 10rpx;
  300. }
  301. }
  302. .chooseAvatar::after{
  303. border: none;
  304. padding: 0 !important;
  305. margin: 0 !important;
  306. }
  307. .nickname{
  308. background-color: #f7f7f7;
  309. width: 600rpx;
  310. height: 80rpx;
  311. text-align: center;
  312. border-radius: 40rpx;
  313. margin-top: 30rpx;
  314. }
  315. .line {
  316. display: flex;
  317. justify-content: space-between;
  318. align-items: center;
  319. background-color: #f7f7f7;
  320. width: 600rpx;
  321. height: 80rpx;
  322. padding: 0 30rpx;
  323. margin: 0 auto;
  324. border-radius: 40rpx;
  325. margin-top: 30rpx;
  326. box-sizing: border-box;
  327. .getPhoneNumber{
  328. // all: unset;
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. // background: $uni-linear-gradient-btn-color;
  333. background: $uni-color;
  334. color: #fff;
  335. width: 200rpx;
  336. height: 60rpx;
  337. border-radius: 30rpx;
  338. font-size: 24rpx;
  339. }
  340. }
  341. .sexSelect{
  342. background-color: #f7f7f7;
  343. width: 600rpx;
  344. height: 80rpx;
  345. text-align: center;
  346. border-radius: 40rpx;
  347. margin-top: 30rpx;
  348. display: flex;
  349. align-items: center;
  350. font-size: 26rpx;
  351. line-height: 80rpx;
  352. overflow: hidden;
  353. &>view{
  354. flex: 1;
  355. display: flex;
  356. justify-content: center;
  357. align-content: center;
  358. height: 100%;
  359. }
  360. &>view:nth-child(1){
  361. border-right: 1px solid #000;
  362. }
  363. }
  364. .address{
  365. background-color: #f7f7f7;
  366. width: 600rpx;
  367. height: 80rpx;
  368. text-align: center;
  369. border-radius: 40rpx;
  370. margin-top: 30rpx;
  371. line-height: 80rpx;
  372. color: #555;
  373. }
  374. .school-input{
  375. background-color: #f7f7f7;
  376. width: 600rpx;
  377. height: 80rpx;
  378. text-align: center;
  379. border-radius: 40rpx;
  380. margin-top: 30rpx;
  381. padding: 0 30rpx;
  382. box-sizing: border-box;
  383. color: #333;
  384. }
  385. .btn {
  386. // background: $uni-linear-gradient-btn-color;
  387. background: $uni-color;
  388. color: #fff;
  389. width: 80%;
  390. padding: 20rpx 0;
  391. text-align: center;
  392. border-radius: 15rpx;
  393. margin-top: 10vh;
  394. }
  395. }
  396. </style>