index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <view class="">
  3. <!-- <view class="text-center text-white bg-red">18岁以上方可认证使用</view> -->
  4. <view class="margin padding-lr bg-white" style="border-radius: 16rpx">
  5. <view class="flex justify-between align-center" style="border-bottom: 2rpx solid #e6e6e6; color: #1a1a1a">
  6. <view class="padding-tb text-lg text-bold">申请信息</view>
  7. <view class="text-df" style="color: #666666">注:18岁以上方可认证使用</view>
  8. </view>
  9. <view class="flex align-center padding-tb">
  10. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">你的生日</view>
  11. <view class="flex align-center">
  12. <!-- <view class="margin-right-xs text-gray">2020年4月2日</view> -->
  13. <input @click="isShow" v-model="birthday" class="margin-right-xs" disabled placeholder="请填写你的生日" style="text-align: right" type="text" />
  14. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  15. </view>
  16. </view>
  17. <view class="flex align-center padding-tb">
  18. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">你的性别</view>
  19. <view class="flex align-center">
  20. <u-radio-group v-model="sex">
  21. <u-radio v-for="(item, index) in gender" :key="index" :name="item.name">{{ item.name }}</u-radio>
  22. </u-radio-group>
  23. </view>
  24. </view>
  25. <view class="flex align-center padding-tb">
  26. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">你的身高(CM)</view>
  27. <view class="flex align-center">
  28. <!-- <view class="margin-right-xs text-gray">170cm</view> -->
  29. <input class="margin-right-xs" v-model="height" placeholder="请填写你的身高" style="text-align: right" type="text" />
  30. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  31. </view>
  32. </view>
  33. <view class="flex align-center padding-tb">
  34. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">你的体重(KG)</view>
  35. <view class="flex align-center">
  36. <!-- <view class="margin-right-xs text-gray">50kg</view> -->
  37. <input class="margin-right-xs" v-model="weight" placeholder="请填写你的体重" style="text-align: right" type="text" />
  38. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  39. </view>
  40. </view>
  41. <view class="flex align-center padding-tb">
  42. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">你的职业</view>
  43. <view class="flex align-center">
  44. <!-- <view class="margin-right-xs text-gray">设计</view> -->
  45. <input class="margin-right-xs" v-model="occupation" placeholder="请填写你的职业" style="text-align: right" type="text" />
  46. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  47. </view>
  48. </view>
  49. </view>
  50. <view class="margin padding bg-white" style="border-radius: 16rpx">
  51. <view class="flex align-center padding-tb">
  52. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">真实姓名</view>
  53. <view class="flex align-center">
  54. <!-- <view class="margin-right-xs text-gray">设计</view> -->
  55. <input class="margin-right-xs" v-model="realName" placeholder="请填写你的真实姓名" style="text-align: right" type="text" />
  56. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  57. </view>
  58. </view>
  59. <view class="flex align-center padding-tb">
  60. <view class="flex-sub text-df text-bold" style="color: #1a1a1a">
  61. 身份证号
  62. <text class="text-red">*</text>
  63. </view>
  64. <view class="flex align-center">
  65. <!-- <view class="margin-right-xs text-gray">设计</view> -->
  66. <input class="margin-right-xs" v-model="identityCardNum" placeholder="请填写你的身份证号" style="text-align: right" type="text" />
  67. <!-- <image src="../../static/images/orderReceiving/right.png" style="width: 16rpx;height: 26rpx;"></image> -->
  68. </view>
  69. </view>
  70. <view class="text-lg text-bold text-black margin-bottom-sm">上传身份证正面</view>
  71. <view class="margin-top" style="border: 2rpx dashed #484b74; width: 100%; height: 320rpx; position: relative">
  72. <view style="text-align: center; margin: 80rpx auto 0" @click="addIDCard(1)" v-if="!identityCardFront">
  73. <image src="../../static/images/index/add.png" mode="widthFix" style="width: 73rpx"></image>
  74. <view class="text-sm text-gray margin-top-sm">添加身份证正面</view>
  75. </view>
  76. <image @click="addIDCard(1)" v-else :src="identityCardFront" style="width: 100%; height: 320rpx"></image>
  77. </view>
  78. <view class="text-lg text-bold text-black margin-tb-sm">上传身份证反面</view>
  79. <view class="margin-top" style="border: 2rpx dashed #484b74; width: 100%; height: 320rpx; position: relative">
  80. <view style="text-align: center; margin: 80rpx auto 0" @click="addIDCard(2)" v-if="!identityCardRear">
  81. <image src="../../static/images/index/add.png" mode="widthFix" style="width: 73rpx"></image>
  82. <view class="text-sm text-gray margin-top-sm">添加身份证反面</view>
  83. </view>
  84. <image @click="addIDCard(2)" v-else :src="identityCardRear" style="width: 100%; height: 320rpx"></image>
  85. </view>
  86. </view>
  87. <view class="margin padding bg-white" style="border-radius: 16rpx">
  88. <view class="text-lg text-bold text-black margin-bottom-sm">个人简介</view>
  89. <textarea class="radius" v-model="individualResume" style="width: 100%; height: 150rpx; background: #f5f5f5; padding: 15rpx" placeholder="请输入个人简介"></textarea>
  90. <view class="text-lg text-bold text-black margin-tb-sm">图片上传</view>
  91. <view class="flex flex-wrap">
  92. <view
  93. class="flex"
  94. v-if="infantImgs.length"
  95. style="width: 200rpx; height: 200rpx; margin-right: 10rpx; position: relative; margin-bottom: 10rpx"
  96. v-for="(image, index) in infantImgs"
  97. :key="index"
  98. >
  99. <image :src="image" class="radius" style="width: 100%; height: 100%" @click="previewImg(index)"></image>
  100. <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="infantImgremove(index)">
  101. <u-icon name="close-circle-fill" color="red" size="50rpx"></u-icon>
  102. </view>
  103. </view>
  104. <view v-if="infantImgs.length < 9" style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center radius" @click="addImages()">
  105. <view>
  106. <view class="text-center">
  107. <image src="../../static/images/index/add.png" style="width: 65rpx; height: 55rpx"></image>
  108. </view>
  109. <view class="text-center">添加图片</view>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="text-lg text-bold text-black margin-tb-sm">视频上传</view>
  114. <view>
  115. <view v-if="!video" style="width: 200rpx; height: 200rpx; background: #f4f5f6" class="flex justify-center align-center radius" @click="addVideo()">
  116. <view>
  117. <view class="text-center">
  118. <image src="../../static/images/index/add.png" style="width: 65rpx; height: 55rpx"></image>
  119. </view>
  120. <view class="text-center">添加视频</view>
  121. </view>
  122. </view>
  123. <view class="flex" v-if="video" style="width: 100%; position: relative">
  124. <video :src="video" controls></video>
  125. <view style="z-index: 9; position: absolute; top: -15rpx; right: -15rpx" @click="removeVidoe()">
  126. <u-icon name="close-circle-fill" color="red" size="50rpx"></u-icon>
  127. </view>
  128. </view>
  129. </view>
  130. <!-- </view> -->
  131. </view>
  132. <view class="margin">
  133. <view class="text-center text-lg radius text-bold" style="width: 100%; height: 78rpx; line-height: 78rpx; background: #7e59ff; color: #fff" @click="fabuBtn()">
  134. {{ btnName }}
  135. </view>
  136. </view>
  137. <u-picker @confirm="timeAction" v-model="show" :params="params" mode="time"></u-picker>
  138. <!-- 用于图片压缩的canvas画布 -->
  139. <canvas
  140. :style="{
  141. width: cw + 'px',
  142. height: cw + 'px',
  143. position: 'absolute',
  144. zIndex: -1,
  145. left: '-10000rpx',
  146. top: '-10000rpx'
  147. }"
  148. canvas-id="zipCanvas"
  149. ></canvas>
  150. <!--画布结束-->
  151. </view>
  152. </template>
  153. <script>
  154. import getLessLimitSizeImage from '@/utils/imageCompress.js'
  155. export default {
  156. data() {
  157. return {
  158. fileList: [],
  159. show: false,
  160. params: {
  161. year: true,
  162. month: true,
  163. day: true
  164. },
  165. birthday: '', //生日
  166. height: '', //身高
  167. weight: '', //体重
  168. occupation: '', //职业
  169. individualResume: '', //简介
  170. pictureList: [],
  171. realName: '', //姓名
  172. identityCardNum: '', //身份证号
  173. identityCardFront: '', //身份证正面
  174. identityCardRear: '', //身份证反面
  175. gender: [
  176. {
  177. name: '男',
  178. checked: true
  179. },
  180. {
  181. name: '女',
  182. checked: false
  183. }
  184. ],
  185. sex: '男',
  186. userId: '',
  187. btnName: '提交申请',
  188. video: '',
  189. isFinish: false,
  190. infantImgs: [],
  191. //画板边长默认是屏幕宽度,正方形画布
  192. cw: uni.getSystemInfoSync().windowWidth
  193. }
  194. },
  195. onLoad(option) {
  196. this.userId = option.userId ? option.userId : ''
  197. if (this.userId) {
  198. // this.getUserInfo()
  199. }
  200. uni.setNavigationBarTitle({
  201. title: '修改个人信息'
  202. })
  203. this.btnName = '提交修改'
  204. this.getPWInfo()
  205. },
  206. methods: {
  207. // 上传视频
  208. addVideo() {
  209. let that=this
  210. let token = uni.getStorageSync('token')
  211. uni.chooseVideo({
  212. count: 1,
  213. sourceType: ['album', 'camera'],
  214. success: (res) => {
  215. this.$queue.showLoading('上传中...')
  216. console.log(res.tempFilePath)
  217. uni.uploadFile({
  218. // 上传接口
  219. // url: this.config("APIHOST1") + '/app/new-file/upload', //真实的接口地址
  220. url: that.config('APIHOST1') + '/app/new-file/upload',
  221. filePath: res.tempFilePath,
  222. header: {
  223. token: token
  224. },
  225. name: 'file',
  226. timeout: '30000',
  227. success: (uploadFileRes) => {
  228. // console.log(JSON.parse(uploadFileRes.data))
  229. this.video = JSON.parse(uploadFileRes.data).data
  230. console.log(this.video)
  231. uni.hideLoading()
  232. }
  233. })
  234. }
  235. })
  236. },
  237. // 删除视频
  238. removeVidoe() {
  239. this.video = ''
  240. },
  241. addIDCard(e) {
  242. uni.chooseImage({
  243. count: 1,
  244. sourceType: ['album', 'camera'],
  245. success: (res) => {
  246. for (let i = 0; i < 1; i++) {
  247. //这里的id和页面中写的html代码的canvas的id要一致
  248. let canvasId = 'zipCanvas'
  249. //原图的路径
  250. let imagePath = res.tempFiles[i].path
  251. //大小限制
  252. let limitSize = 1024 * 2
  253. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  254. let drawWidth = uni.getSystemInfoSync().windowWidth
  255. let that = this
  256. let token = uni.getStorageSync('token')
  257. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  258. uni.showLoading({
  259. title: '上传中'
  260. })
  261. uni.uploadFile({
  262. url: that.config('APIHOST1') + '/app/new-file/upload',
  263. filePath: resPath,
  264. header: {
  265. token: token
  266. },
  267. name: 'file',
  268. success: (uploadFileRes) => {
  269. if (e == 1) {
  270. this.identityCardFront = JSON.parse(uploadFileRes.data).data
  271. } else {
  272. this.identityCardRear = JSON.parse(uploadFileRes.data).data
  273. }
  274. uni.hideLoading()
  275. },
  276. fail: () => {
  277. uni.showToast({
  278. title: '上传失败',
  279. icon: 'error'
  280. })
  281. }
  282. })
  283. })
  284. }
  285. }
  286. })
  287. },
  288. // 上传照片
  289. addImages(e) {
  290. uni.chooseImage({
  291. count: 9,
  292. sourceType: ['album', 'camera'],
  293. success: (res) => {
  294. for (let i = 0; i < res.tempFiles.length; i++) {
  295. //这里的id和页面中写的html代码的canvas的id要一致
  296. let canvasId = 'zipCanvas'
  297. //原图的路径
  298. let imagePath = res.tempFiles[i].path
  299. //大小限制
  300. let limitSize = 1024 * 2
  301. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  302. let drawWidth = uni.getSystemInfoSync().windowWidth
  303. let that = this
  304. let token = uni.getStorageSync('token')
  305. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  306. uni.showLoading({
  307. title: '上传中'
  308. })
  309. uni.uploadFile({
  310. url: that.config('APIHOST1') + '/app/new-file/upload',
  311. filePath: resPath,
  312. header: {
  313. token: token
  314. },
  315. name: 'file',
  316. success: (uploadFileRes) => {
  317. if (this.infantImgs.length < 9) {
  318. this.infantImgs.push(JSON.parse(uploadFileRes.data).data)
  319. }
  320. uni.hideLoading()
  321. },
  322. fail: () => {
  323. uni.showToast({
  324. title: '上传失败',
  325. icon: 'error'
  326. })
  327. }
  328. })
  329. })
  330. }
  331. }
  332. })
  333. },
  334. // 删除照片
  335. infantImgremove(index) {
  336. this.infantImgs.splice(index, 1)
  337. },
  338. // 预览照片
  339. previewImg(index) {
  340. let _this = this
  341. uni.previewImage({
  342. current: index,
  343. urls: _this.infantImgs
  344. })
  345. },
  346. getPWInfo() {
  347. this.$Request.getT('/app/usermessage/findPwUserMessage').then((res) => {
  348. if (res.code == 0) {
  349. // if (res.data.auditStatus == 0) {
  350. this.birthday = res.data.birthday //生日
  351. this.height = res.data.height //身高
  352. this.weight = res.data.weight //体重
  353. this.sex = res.data.sex == 1 ? '男' : '女'
  354. this.occupation = res.data.occupation //职业
  355. this.individualResume = res.data.individualResume //简介
  356. this.realName = res.data.realName //姓名
  357. this.identityCardNum = res.data.identityCardNum //身份证号
  358. this.identityCardFront = res.data.identityCardFront //身份证正面
  359. this.identityCardRear = res.data.identityCardRear //身份证反面
  360. this.pictureList = res.data.pictureList.split(',')
  361. this.video = res.data.video
  362. this.infantImgs = []
  363. this.pictureList.forEach((res) => {
  364. this.infantImgs.push(res)
  365. })
  366. // }
  367. }
  368. })
  369. },
  370. getUserInfo() {
  371. let data = {
  372. userId: this.userId
  373. }
  374. this.$Request.getT('/app/payorder/selectUserMessageById', data).then((res) => {
  375. if (res.code == 0) {
  376. console.log(res.data)
  377. this.birthday = res.data.birthday //生日
  378. this.height = res.data.height //身高
  379. this.weight = res.data.weight //体重
  380. this.occupation = res.data.occupation //职业
  381. this.individualResume = res.data.individualResume //简介
  382. this.realName = res.data.realName //姓名
  383. this.identityCardNum = res.data.identityCardNum //身份证号
  384. this.identityCardFront = res.data.identityCardFront //身份证正面
  385. this.identityCardRear = res.data.identityCardRear //身份证反面
  386. this.sex = res.data.sex == 1 ? '男' : '女'
  387. this.pictureList = res.data.pictureList.split(',')
  388. this.video = res.data.video
  389. this.infantImgs = []
  390. this.pictureList.forEach((res) => {
  391. this.infantImgs.push(res)
  392. })
  393. }
  394. })
  395. },
  396. isShow() {
  397. this.show = true
  398. },
  399. timeAction(e) {
  400. console.log(e)
  401. this.birthday = e.year + '-' + e.month + '-' + e.day
  402. },
  403. // 发布
  404. fabuBtn() {
  405. let that = this
  406. if (!that.birthday) {
  407. uni.showToast({
  408. title: '请填写你的生日',
  409. icon: 'none'
  410. })
  411. return
  412. }
  413. if (!that.height) {
  414. uni.showToast({
  415. title: '请填写你的身高',
  416. icon: 'none'
  417. })
  418. return
  419. }
  420. if (!that.weight) {
  421. uni.showToast({
  422. title: '请填写你的体重',
  423. icon: 'none'
  424. })
  425. return
  426. }
  427. if (!that.occupation) {
  428. uni.showToast({
  429. title: '请填写你的职业',
  430. icon: 'none'
  431. })
  432. return
  433. }
  434. if (!that.realName) {
  435. uni.showToast({
  436. title: '请填写你的真实姓名',
  437. icon: 'none'
  438. })
  439. return
  440. }
  441. if (!that.identityCardNum) {
  442. uni.showToast({
  443. title: '请填写你的身份证号',
  444. icon: 'none'
  445. })
  446. return
  447. }
  448. if (!that.identityCardFront) {
  449. uni.showToast({
  450. title: '请上传你的身份证正面',
  451. icon: 'none'
  452. })
  453. return
  454. }
  455. if (!that.identityCardRear) {
  456. uni.showToast({
  457. title: '请上传你的身份证反面',
  458. icon: 'none'
  459. })
  460. return
  461. }
  462. console.log(that.infantImgs, 'lenght', that.infantImgs.length)
  463. if (that.infantImgs.length < 9) {
  464. uni.showToast({
  465. title: '请上传9张你的照片',
  466. icon: 'none'
  467. })
  468. return
  469. }
  470. if (!that.video) {
  471. uni.showToast({
  472. title: '请上传你的视频',
  473. icon: 'none'
  474. })
  475. return
  476. }
  477. console.log(that.isFinish)
  478. console.log(that.infantImgs)
  479. // return
  480. let data = {
  481. birthday: that.birthday, //生日
  482. sex: that.sex == '男' ? 1 : 2, //性别
  483. height: that.height, //身高
  484. weight: that.weight, //体重
  485. occupation: that.occupation, //职业
  486. individualResume: that.individualResume, //简介
  487. pictureList: that.infantImgs.toString(),
  488. realName: that.realName,
  489. identityCardNum: that.identityCardNum,
  490. identityCardFront: that.identityCardFront,
  491. identityCardRear: that.identityCardRear,
  492. video: that.video
  493. }
  494. if (that.userId) {
  495. uni.showModal({
  496. title: '提示',
  497. content: '修改资料预计24小时后通过审核,审核期间将不能接单,是否继续?',
  498. confirmText: '继续',
  499. success: function (res) {
  500. if (res.confirm) {
  501. console.log('用户点击确定')
  502. that.$Request.postJson('/app/usermessage/updateUserMessage', data).then((res) => {
  503. // console.log(that.res)
  504. if (res.code == 0) {
  505. uni.showToast({
  506. title: '提交成功'
  507. })
  508. setTimeout(function () {
  509. uni.switchTab({
  510. url: '/pages/my/index'
  511. })
  512. }, 1000)
  513. } else {
  514. uni.showToast({
  515. title: res.msg,
  516. icon: 'none'
  517. })
  518. }
  519. })
  520. } else if (res.cancel) {
  521. console.log('用户点击取消')
  522. }
  523. }
  524. })
  525. } else {
  526. that.$Request.postJson('/app/usermessage/applyPw', data).then((res) => {
  527. console.log(that.res)
  528. if (res.code == 0) {
  529. uni.showToast({
  530. title: '申请成功'
  531. })
  532. setTimeout(function () {
  533. uni.switchTab({
  534. url: '/pages/my/index'
  535. })
  536. }, 1000)
  537. } else {
  538. uni.showToast({
  539. title: res.msg,
  540. icon: 'none'
  541. })
  542. }
  543. })
  544. }
  545. }
  546. }
  547. }
  548. </script>
  549. <style>
  550. page {
  551. /* background-color: #FFF; */
  552. }
  553. </style>