index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. action: 'https://newxxpw.xianmxkj.com/sqx_fast/alioss/upload',
  159. fileList: [],
  160. show: false,
  161. params: {
  162. year: true,
  163. month: true,
  164. day: true
  165. },
  166. birthday: '', //生日
  167. height: '', //身高
  168. weight: '', //体重
  169. occupation: '', //职业
  170. individualResume: '', //简介
  171. pictureList: [],
  172. realName: '', //姓名
  173. identityCardNum: '', //身份证号
  174. identityCardFront: '', //身份证正面
  175. identityCardRear: '', //身份证反面
  176. gender: [
  177. {
  178. name: '男',
  179. checked: true
  180. },
  181. {
  182. name: '女',
  183. checked: false
  184. }
  185. ],
  186. sex: '男',
  187. userId: '',
  188. btnName: '提交申请',
  189. video: '',
  190. isFinish: false,
  191. infantImgs: [],
  192. //画板边长默认是屏幕宽度,正方形画布
  193. cw: uni.getSystemInfoSync().windowWidth
  194. }
  195. },
  196. onLoad(option) {
  197. this.userId = option.userId ? option.userId : ''
  198. if (this.userId) {
  199. // this.getUserInfo()
  200. }
  201. uni.setNavigationBarTitle({
  202. title: '修改个人信息'
  203. })
  204. this.btnName = '提交修改'
  205. this.getPWInfo()
  206. },
  207. methods: {
  208. // 上传视频
  209. addVideo() {
  210. uni.chooseVideo({
  211. count: 1,
  212. sourceType: ['album', 'camera'],
  213. success: (res) => {
  214. this.$queue.showLoading('上传中...')
  215. console.log(res.tempFilePath)
  216. uni.uploadFile({
  217. // 上传接口
  218. // url: this.config("APIHOST1") + '/alioss/upload', //真实的接口地址
  219. url: 'https://newxxpw.xianmxkj.com/sqx_fast/alioss/upload',
  220. filePath: res.tempFilePath,
  221. name: 'file',
  222. timeout: '30000',
  223. success: (uploadFileRes) => {
  224. // console.log(JSON.parse(uploadFileRes.data))
  225. this.video = JSON.parse(uploadFileRes.data).data
  226. console.log(this.video)
  227. uni.hideLoading()
  228. }
  229. })
  230. }
  231. })
  232. },
  233. // 删除视频
  234. removeVidoe() {
  235. this.video = ''
  236. },
  237. addIDCard(e) {
  238. uni.chooseImage({
  239. count: 1,
  240. sourceType: ['album', 'camera'],
  241. success: (res) => {
  242. for (let i = 0; i < 1; i++) {
  243. //这里的id和页面中写的html代码的canvas的id要一致
  244. let canvasId = 'zipCanvas'
  245. //原图的路径
  246. let imagePath = res.tempFiles[i].path
  247. //大小限制
  248. let limitSize = 1024 * 2
  249. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  250. let drawWidth = uni.getSystemInfoSync().windowWidth
  251. let that = this
  252. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  253. uni.showLoading({
  254. title: '上传中'
  255. })
  256. uni.uploadFile({
  257. url: 'https://newxxpw.xianmxkj.com/sqx_fast/alioss/upload',
  258. filePath: resPath,
  259. name: 'file',
  260. success: (uploadFileRes) => {
  261. if (e == 1) {
  262. this.identityCardFront = JSON.parse(uploadFileRes.data).data
  263. } else {
  264. this.identityCardRear = JSON.parse(uploadFileRes.data).data
  265. }
  266. uni.hideLoading()
  267. },
  268. fail: () => {
  269. uni.showToast({
  270. title: '上传失败',
  271. icon: 'error'
  272. })
  273. }
  274. })
  275. })
  276. }
  277. }
  278. })
  279. },
  280. // 上传照片
  281. addImages(e) {
  282. uni.chooseImage({
  283. count: 9,
  284. sourceType: ['album', 'camera'],
  285. success: (res) => {
  286. for (let i = 0; i < res.tempFiles.length; i++) {
  287. //这里的id和页面中写的html代码的canvas的id要一致
  288. let canvasId = 'zipCanvas'
  289. //原图的路径
  290. let imagePath = res.tempFiles[i].path
  291. //大小限制
  292. let limitSize = 1024 * 2
  293. //初始绘画区域是画布自身的宽度也就是屏幕宽度
  294. let drawWidth = uni.getSystemInfoSync().windowWidth
  295. let that = this
  296. getLessLimitSizeImage(canvasId, imagePath, limitSize, drawWidth, that, (resPath) => {
  297. uni.showLoading({
  298. title: '上传中'
  299. })
  300. uni.uploadFile({
  301. url: 'https://newxxpw.xianmxkj.com/sqx_fast/alioss/upload',
  302. filePath: resPath,
  303. name: 'file',
  304. success: (uploadFileRes) => {
  305. if (this.infantImgs.length < 9) {
  306. this.infantImgs.push(JSON.parse(uploadFileRes.data).data)
  307. }
  308. uni.hideLoading()
  309. },
  310. fail: () => {
  311. uni.showToast({
  312. title: '上传失败',
  313. icon: 'error'
  314. })
  315. }
  316. })
  317. })
  318. }
  319. }
  320. })
  321. },
  322. // 删除照片
  323. infantImgremove(index) {
  324. this.infantImgs.splice(index, 1)
  325. },
  326. // 预览照片
  327. previewImg(index) {
  328. let _this = this
  329. uni.previewImage({
  330. current: index,
  331. urls: _this.infantImgs
  332. })
  333. },
  334. getPWInfo() {
  335. this.$Request.getT('/app/usermessage/findPwUserMessage').then((res) => {
  336. if (res.code == 0) {
  337. // if (res.data.auditStatus == 0) {
  338. this.birthday = res.data.birthday //生日
  339. this.height = res.data.height //身高
  340. this.weight = res.data.weight //体重
  341. this.sex = res.data.sex == 1 ? '男' : '女'
  342. this.occupation = res.data.occupation //职业
  343. this.individualResume = res.data.individualResume //简介
  344. this.realName = res.data.realName //姓名
  345. this.identityCardNum = res.data.identityCardNum //身份证号
  346. this.identityCardFront = res.data.identityCardFront //身份证正面
  347. this.identityCardRear = res.data.identityCardRear //身份证反面
  348. this.pictureList = res.data.pictureList.split(',')
  349. this.video = res.data.video
  350. this.infantImgs = []
  351. this.pictureList.forEach((res) => {
  352. this.infantImgs.push(res)
  353. })
  354. // }
  355. }
  356. })
  357. },
  358. getUserInfo() {
  359. let data = {
  360. userId: this.userId
  361. }
  362. this.$Request.getT('/app/payorder/selectUserMessageById', data).then((res) => {
  363. if (res.code == 0) {
  364. console.log(res.data)
  365. this.birthday = res.data.birthday //生日
  366. this.height = res.data.height //身高
  367. this.weight = res.data.weight //体重
  368. this.occupation = res.data.occupation //职业
  369. this.individualResume = res.data.individualResume //简介
  370. this.realName = res.data.realName //姓名
  371. this.identityCardNum = res.data.identityCardNum //身份证号
  372. this.identityCardFront = res.data.identityCardFront //身份证正面
  373. this.identityCardRear = res.data.identityCardRear //身份证反面
  374. this.sex = res.data.sex == 1 ? '男' : '女'
  375. this.pictureList = res.data.pictureList.split(',')
  376. this.video = res.data.video
  377. this.infantImgs = []
  378. this.pictureList.forEach((res) => {
  379. this.infantImgs.push(res)
  380. })
  381. }
  382. })
  383. },
  384. isShow() {
  385. this.show = true
  386. },
  387. timeAction(e) {
  388. console.log(e)
  389. this.birthday = e.year + '-' + e.month + '-' + e.day
  390. },
  391. // 发布
  392. fabuBtn() {
  393. let that = this
  394. if (!that.birthday) {
  395. uni.showToast({
  396. title: '请填写你的生日',
  397. icon: 'none'
  398. })
  399. return
  400. }
  401. if (!that.height) {
  402. uni.showToast({
  403. title: '请填写你的身高',
  404. icon: 'none'
  405. })
  406. return
  407. }
  408. if (!that.weight) {
  409. uni.showToast({
  410. title: '请填写你的体重',
  411. icon: 'none'
  412. })
  413. return
  414. }
  415. if (!that.occupation) {
  416. uni.showToast({
  417. title: '请填写你的职业',
  418. icon: 'none'
  419. })
  420. return
  421. }
  422. if (!that.realName) {
  423. uni.showToast({
  424. title: '请填写你的真实姓名',
  425. icon: 'none'
  426. })
  427. return
  428. }
  429. if (!that.identityCardNum) {
  430. uni.showToast({
  431. title: '请填写你的身份证号',
  432. icon: 'none'
  433. })
  434. return
  435. }
  436. if (!that.identityCardFront) {
  437. uni.showToast({
  438. title: '请上传你的身份证正面',
  439. icon: 'none'
  440. })
  441. return
  442. }
  443. if (!that.identityCardRear) {
  444. uni.showToast({
  445. title: '请上传你的身份证反面',
  446. icon: 'none'
  447. })
  448. return
  449. }
  450. console.log(that.infantImgs, 'lenght', that.infantImgs.length)
  451. if (that.infantImgs.length < 9) {
  452. uni.showToast({
  453. title: '请上传9张你的照片',
  454. icon: 'none'
  455. })
  456. return
  457. }
  458. if (!that.video) {
  459. uni.showToast({
  460. title: '请上传你的视频',
  461. icon: 'none'
  462. })
  463. return
  464. }
  465. console.log(that.isFinish)
  466. console.log(that.infantImgs)
  467. // return
  468. let data = {
  469. birthday: that.birthday, //生日
  470. sex: that.sex == '男' ? 1 : 2, //性别
  471. height: that.height, //身高
  472. weight: that.weight, //体重
  473. occupation: that.occupation, //职业
  474. individualResume: that.individualResume, //简介
  475. pictureList: that.infantImgs.toString(),
  476. realName: that.realName,
  477. identityCardNum: that.identityCardNum,
  478. identityCardFront: that.identityCardFront,
  479. identityCardRear: that.identityCardRear,
  480. video: that.video
  481. }
  482. if (that.userId) {
  483. uni.showModal({
  484. title: '提示',
  485. content: '修改资料预计24小时后通过审核,审核期间将不能接单,是否继续?',
  486. confirmText: '继续',
  487. success: function (res) {
  488. if (res.confirm) {
  489. console.log('用户点击确定')
  490. that.$Request.postJson('/app/usermessage/updateUserMessage', data).then((res) => {
  491. // console.log(that.res)
  492. if (res.code == 0) {
  493. uni.showToast({
  494. title: '提交成功'
  495. })
  496. setTimeout(function () {
  497. uni.switchTab({
  498. url: '/pages/my/index'
  499. })
  500. }, 1000)
  501. } else {
  502. uni.showToast({
  503. title: res.msg,
  504. icon: 'none'
  505. })
  506. }
  507. })
  508. } else if (res.cancel) {
  509. console.log('用户点击取消')
  510. }
  511. }
  512. })
  513. } else {
  514. that.$Request.postJson('/app/usermessage/applyPw', data).then((res) => {
  515. console.log(that.res)
  516. if (res.code == 0) {
  517. uni.showToast({
  518. title: '申请成功'
  519. })
  520. setTimeout(function () {
  521. uni.switchTab({
  522. url: '/pages/my/index'
  523. })
  524. }, 1000)
  525. } else {
  526. uni.showToast({
  527. title: res.msg,
  528. icon: 'none'
  529. })
  530. }
  531. })
  532. }
  533. }
  534. }
  535. }
  536. </script>
  537. <style>
  538. page {
  539. /* background-color: #FFF; */
  540. }
  541. </style>