settledShipyard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view class="content">
  3. <view v-if="state == 0">
  4. <view class="box">
  5. <view class="title">船厂信息</view>
  6. <view class="cell vflex">
  7. <view class="img_title">船厂头像</view>
  8. <view style="width: 220rpx;height: 220rpx;padding-top: 28rpx;">
  9. <u-upload :fileList="info.fileList1" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="1" multiple :previewFullImage="true" width="220rpx" height="220rpx">
  10. <view class="vflex acenter jcenter upload_bg">
  11. <u-icon name="plus" color="#929292" size="20"></u-icon>
  12. <view class="upload_text">上传图片</view>
  13. </view>
  14. </u-upload>
  15. </view>
  16. </view>
  17. <view class="hflex acenter jbetween cell">
  18. <view class="left">船厂名称</view>
  19. <u-input v-model="info.name" border="none" placeholder="请输入船厂名称" inputAlign="right"></u-input>
  20. </view>
  21. <view class="hflex acenter jbetween cell" @click="selectmap">
  22. <view class="left">船厂地址</view>
  23. <u-input v-model="addressObj.address" border="none" disabled disabledColor="#fff" placeholder="请选择" inputAlign="right" suffixIcon="map-fill" suffixIconStyle="color: #B7B7B7"></u-input>
  24. </view>
  25. <view class="hflex acenter jbetween cell">
  26. <view class="left">联系人</view>
  27. <u-input v-model="info.contacts" border="none" placeholder="请输入联系人姓名" inputAlign="right"></u-input>
  28. </view>
  29. <view class="hflex acenter jbetween cell">
  30. <view class="left">联系电话</view>
  31. <u-input v-model="info.phone" border="none" placeholder="请输入联系电话" inputAlign="right"></u-input>
  32. </view>
  33. <view class="vflex cell" style="border: none;">
  34. <view class="left">船厂简介</view>
  35. <u--textarea v-model="info.introduction" placeholder="在此输入船厂简介内容" ></u--textarea>
  36. </view>
  37. <view class="vflex">
  38. <view class="img_title">船厂环境</view>
  39. <view class="hflex fwrap" style="padding-top: 28rpx;">
  40. <u-upload :fileList="info.fileList2" @afterRead="afterRead" @delete="deletePic" :maxCount="9" name="2" multiple :previewFullImage="true" width="200rpx" height="200rpx">
  41. <view class="vflex acenter jcenter upload_bg">
  42. <u-icon name="plus" color="#929292" size="20"></u-icon>
  43. <view class="upload_text">上传图片</view>
  44. </view>
  45. </u-upload>
  46. </view>
  47. </view>
  48. <view class="vflex cell" style="border: none;">
  49. <view class="left">产品简介</view>
  50. <u--textarea v-model="info.product_intro" placeholder="在此输入产品简介内容" ></u--textarea>
  51. </view>
  52. </view>
  53. <view class="box">
  54. <view class="cell" style="border: none;padding: none;">
  55. <view class="img_title">上传营业执照</view>
  56. <view class="upload_img vflex acenter jcenter">
  57. <u-upload :fileList="info.fileList3" @afterRead="afterRead" @delete="deletePic" :maxCount="1" name="3" multiple :previewFullImage="true" width="550rpx" height="324rpx">
  58. <image src="/static/images/comment/upload-business.png" style="width: 550rpx;height: 324rpx;"></image>
  59. </u-upload>
  60. <view class="hflex acenter ">
  61. <u-icon name="camera" color="#999999" size="16"></u-icon>
  62. <view class="">点击上传营业执照</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="hflex acenter">
  68. <u-checkbox-group @change="checkboxChange">
  69. <u-checkbox v-model="agree" shape="circle"></u-checkbox>
  70. </u-checkbox-group>
  71. <view class="text">阅读并同意<span class="read" @click="open">《商家入驻规则》</span></view>
  72. </view>
  73. <view class="button hflex acenter jcenter" @click="settled">
  74. <view>立即入驻</view>
  75. </view>
  76. </view>
  77. <view v-if="state == 1">
  78. <view class="box1 vflex acenter jcenter">
  79. <image src="/static/images/comment/wait.png" class="box1_img"></image>
  80. <view class="box1_title">审核中</view>
  81. <view class="box1_subTitle">预计审核时间3个工作日</view>
  82. <view class="box1_subTitle">请留意当前页面变动</view>
  83. <view class="btn" @click="result">返回</view>
  84. </view>
  85. </view>
  86. <view v-if="state == 2">
  87. <view class="box1 vflex acenter jcenter">
  88. <image src="/static/images/comment/error.png" class="box1_img"></image>
  89. <view class="box1_title">审核失败</view>
  90. <view class="box1_subTitle">驳回原因</view>
  91. <view class="box1_subTitle">{{reason}}<span style="color: #506dff;margin-left: 8rpx;" @click="edit">立即修改></span></view>
  92. <view class="btn" @click="result">返回</view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. <script>
  98. import $api from '@/static/js/api.js'
  99. var that = ''
  100. export default {
  101. data() {
  102. return {
  103. info: {
  104. id: '',
  105. name: '',
  106. address: '',
  107. contacts: '',
  108. phone: '',
  109. introduction: '',
  110. fileList1: [],
  111. fileList2: [],
  112. fileList3: [],
  113. product_intro:''
  114. },
  115. addressObj: {},
  116. agree: false,
  117. state: 0,
  118. reason:'',
  119. fileList1: '',
  120. fileList2: '',
  121. fileList3: '',
  122. }
  123. },
  124. onLoad() {
  125. that = this
  126. that.getPreData()
  127. },
  128. methods: {
  129. getPreData() {
  130. var pages = getCurrentPages()
  131. var prePage = pages[pages.length - 2]
  132. var shipyard = prePage.$vm.user.shipyard
  133. if (shipyard) {
  134. that.info = {
  135. name: shipyard.name,
  136. contacts: shipyard.contact_name,
  137. phone: shipyard.contact_phone,
  138. introduction: shipyard.intro,
  139. fileList1: [],
  140. fileList2: [],
  141. fileList3: [],
  142. product_intro: shipyard.product_intro,
  143. // fileList1: shipyard.business_img.split(','),
  144. id: shipyard.id
  145. }
  146. if(shipyard.head_img !== null) {
  147. that.info.fileList1.push({
  148. url: shipyard.head_img
  149. })
  150. that.fileList1 = shipyard.head_img
  151. }
  152. var imgs = shipyard.environment_imgs.splice(',')
  153. for(var i=0;i<imgs.length;i++) {
  154. that.info.fileList2.push({
  155. url: imgs[i]
  156. })
  157. }
  158. that.fileList2 = shipyard.environment_imgs
  159. that.info.fileList3.push({
  160. url: shipyard.business_img
  161. })
  162. that.fileList3 = shipyard.business_img
  163. console.log(that.info);
  164. that.addressObj = {
  165. address: shipyard.address,
  166. province: shipyard.province,
  167. city:shipyard.city,
  168. area:shipyard.area,
  169. }
  170. that.state = shipyard.audit
  171. that.reason = shipyard.why
  172. }
  173. },
  174. selectmap() {
  175. console.log('选择地址');
  176. uni.getLocation({
  177. type: 'wgs84',
  178. success: (res)=>{
  179. console.log(res);
  180. if(res.longitude && res.latitude){
  181. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  182. }
  183. },
  184. fail:()=>{
  185. uni.getSetting({
  186. success: (res) => {
  187. console.log(res);
  188. var status = res.authSetting;
  189. if(!status['scope.userLocation']){
  190. uni.showModal({
  191. title:"是否授权当前位置",
  192. content:"需要获取您的地理位置,请确认授权,否则地图功能将无法使用",
  193. success:(tip)=>{
  194. if(tip.confirm){
  195. uni.openSetting({
  196. success:(data)=>{
  197. if(data.authSetting['scope.userLocation']===true){
  198. uni.showToast({
  199. title:"授权成功",
  200. icon:"success",
  201. duration:1000
  202. })
  203. uni.getLocation({
  204. type: 'wgs84',
  205. success: (res)=>{
  206. console.log('当前位置的经度:' + res.longitude);
  207. console.log('当前位置的纬度:' + res.latitude);
  208. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  209. }
  210. })
  211. }else{
  212. uni.showToast({
  213. title:"授权失败",
  214. icon:"none",
  215. duration:1000
  216. })
  217. }
  218. }
  219. })
  220. }
  221. }
  222. })
  223. }else{
  224. uni.getLocation({
  225. type: 'wgs84',
  226. success: (res)=>{
  227. console.log('当前位置的经度:' + res.longitude);
  228. console.log('当前位置的纬度:' + res.latitude);
  229. $api.jump('/pages/user/map?lng='+res.longitude+'&lat='+res.latitude)
  230. }
  231. })
  232. }
  233. },
  234. fail: (res) => {
  235. uni.showToast({
  236. title:"调用授权窗口失败",
  237. icon:"none",
  238. duration:1000
  239. })
  240. }
  241. })
  242. }
  243. })
  244. },
  245. // 删除图片
  246. deletePic(event) {
  247. // that.userInfo.imgList.splice(event.index, 1)
  248. console.log(event)
  249. this.info[`fileList${event.name}`].splice(event.index, 1)
  250. },
  251. // 新增图片
  252. async afterRead(event) {
  253. console.log(`fileList${event.name}`);
  254. console.log(this.info[`fileList${event.name}`]);
  255. let lists = [].concat(event.file)
  256. let fileListLen = this.info[`fileList${event.name}`].length
  257. lists.map((item) => {
  258. this.info[`fileList${event.name}`].push({
  259. ...item,
  260. status: 'uploading',
  261. message: '上传中'
  262. })
  263. })
  264. for (let i = 0; i < lists.length; i++) {
  265. const result = await this.uploadFilePromise(lists[i].url)
  266. let item = this.info[`fileList${event.name}`][fileListLen]
  267. this.info[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  268. status: 'success',
  269. message: '',
  270. url: result.url
  271. }))
  272. fileListLen++
  273. }
  274. if(that.info[`fileList${event.name}`].length > 0) {
  275. for(var i=0;i<that.info[`fileList${event.name}`].length;i++) {
  276. if(i == that.info[`fileList${event.name}`].length -1) {
  277. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url
  278. } else {
  279. that[`fileList${event.name}`] += that.info[`fileList${event.name}`][i].url + ','
  280. }
  281. }
  282. }
  283. },
  284. // 上传图片
  285. uploadFilePromise(url) {
  286. return new Promise((resolve, reject) => {
  287. let a = uni.uploadFile({
  288. url: $api.config.baseUrl + '/data/api.auth.Center/upload', // 仅为示例,非真实的接口地址
  289. filePath: url,
  290. name: 'file',
  291. header: {
  292. 'content-type': 'application/x-www-form-urlencoded',
  293. 'api-token': uni.getStorageSync('token').token?uni.getStorageSync('token').token:'',
  294. 'api-name': 'wxapp'
  295. },
  296. formData: {
  297. user: 'test'
  298. },
  299. success: (res) => {
  300. setTimeout(() => {
  301. var data = JSON.parse(res.data)
  302. resolve(data.data)
  303. }, 1000)
  304. }
  305. });
  306. })
  307. },
  308. // 阅读并同意
  309. checkboxChange(n) {
  310. that.agree = !that.agree
  311. },
  312. settled() {
  313. var business_img = ""
  314. console.log(that.addressObj);
  315. if ($api.formCheck(that.info.name,'required')&&$api.formCheck(that.addressObj.address,'required')&&$api.formCheck(that.info.fileList1,'required')&&$api.formCheck(that.info.contacts,'required')&&$api.formCheck(that.info.phone,'phone')&&$api.formCheck(that.info.introduction,'required')) {
  316. if(that.agree) {
  317. $api.req({
  318. url: '/data/api.auth.Center/addupshipyard',
  319. method: 'POST',
  320. data: {
  321. name: that.info.name,
  322. province: that.addressObj.province,
  323. city: that.addressObj.city,
  324. area: that.addressObj.area,
  325. address: that.addressObj.address,
  326. contact_name: that.info.contacts,
  327. contact_phone: that.info.phone,
  328. intro: that.info.introduction,
  329. head_img: that.fileList1,
  330. environment_imgs: that.fileList2,
  331. business_img: that.fileList3,
  332. product_intro: that.info.product_intro,
  333. id: that.info.id?that.info.id: ''
  334. }
  335. }, function(res) {
  336. if(res.code == 1) {
  337. $api.info(res.info)
  338. that.state = 1
  339. }
  340. })
  341. }else {
  342. $api.info('请先阅读并同意《商家入驻规则》')
  343. }
  344. }
  345. },
  346. edit() {
  347. that.state = 0
  348. },
  349. result() {
  350. $api.jump('/pages/tabbar/mine/mine',3)
  351. }
  352. },
  353. }
  354. </script>
  355. <style lang="scss" scoped>
  356. .content::v-deep {
  357. background: #F4F4F4;
  358. padding: 20rpx 30rpx;
  359. .box {
  360. width: 100%;
  361. background: #FFFFFF;
  362. border-radius: 28rpx;
  363. padding: 28rpx 20rpx;
  364. box-sizing: border-box;
  365. margin-bottom: 16rpx;
  366. .title {
  367. font-size: 32rpx;
  368. color: #222222;
  369. font-weight: 600;
  370. line-height: 44px;
  371. }
  372. .upload_bg {
  373. width: 200rpx;
  374. height: 200rpx;
  375. background: #F4F4F4;
  376. border-radius: 20rpx;
  377. }
  378. .upload_text {
  379. font-size: 26rpx;
  380. font-weight: 400;
  381. color: #777777;
  382. line-height: 36rpx;
  383. padding-top: 20rpx;
  384. }
  385. .cell {
  386. width: 100%;
  387. padding: 20rpx 0 28rpx;
  388. border-bottom: 1rpx solid #f4f4f4;
  389. .left {
  390. width: 20%;
  391. font-size: 28rpx;
  392. color: #222;
  393. position: relative;
  394. padding-left: 10rpx;
  395. }
  396. .left::before {
  397. content: "*";
  398. position: absolute;
  399. top: 0rpx;
  400. left: -5rpx;
  401. color: #FF0D0D;
  402. font-size: 20rpx;
  403. }
  404. .u-input {
  405. font-size: 28rpx;
  406. color: #222;
  407. }
  408. .img_title {
  409. font-size: 28rpx;
  410. color: #444;
  411. }
  412. .upload_img {
  413. width: 670rpx;
  414. height: 404rpx;
  415. background-color: #fff;
  416. border-radius: 20rpx;
  417. margin: 28rpx 0 0;
  418. padding: 20rpx 0;
  419. border: 1rpx dashed #e0e0e0;
  420. }
  421. .u-upload__wrap {
  422. display: flex;
  423. align-items: center !important;
  424. justify-content: center !important;
  425. }
  426. .u-textarea {
  427. margin: 28rpx auto 0;
  428. background-color: #f4f4f4;
  429. border-radius: 28rpx;
  430. box-sizing: border-box;
  431. padding: 24rpx;
  432. width: 610rpx;
  433. }
  434. }
  435. }
  436. .text {
  437. font-size: 24rpx;
  438. color: #9c9c9c;
  439. }
  440. .read {
  441. color: #2a63f3;
  442. }
  443. .button {
  444. width: 100%;
  445. height: 88rpx;
  446. background-color: #506dff;
  447. border-radius: 50rpx;
  448. box-shadow: 0 4rpx 28rpx 0 rgba(132,123,255,0.4);
  449. font-size: 40rpx;
  450. color: #fff;
  451. margin: 40rpx 0 36rpx;
  452. }
  453. .box1 {
  454. width: 100%;
  455. // height: 100vh;
  456. background-color: #fff;
  457. padding-bottom: 80rpx;
  458. .box1_img {
  459. width: 124rpx;
  460. height: 124rpx;
  461. margin: 108rpx 0 40rpx;
  462. }
  463. .box1_title {
  464. font-size: 32rpx;
  465. color: #222;
  466. margin-bottom: 24rpx;
  467. }
  468. .box1_subTitle {
  469. margin: 12rpx 0;
  470. font-size: 26rpx;
  471. color: #999999;
  472. }
  473. .btn {
  474. width: 530rpx;
  475. height: 88rpx;
  476. background-color: #506dff;
  477. color: #fff;
  478. text-align: center;
  479. line-height: 88rpx;
  480. border-radius: 44rpx;
  481. font-size: 36rpx;
  482. margin-top: 122rpx;
  483. }
  484. }
  485. }
  486. </style>