apply.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. <template>
  2. <app-layout>
  3. <view v-if="status === -1 || form_status">
  4. <view class="apply-com">基本信息</view>
  5. <view class="white">
  6. <view class="dir-left-nowrap cross-center form-input">
  7. <view class="box-grow-0 form-label main-right">联系人</view>
  8. <view class="box-grow-1">
  9. <input @input="applyInput"
  10. :disabled="form_status && status !== 2"
  11. data-type="realname"
  12. placeholder-class="plugins-mch-apply-input"
  13. placeholder="必填"
  14. name="realname"
  15. :value="form.realname"/>
  16. </view>
  17. </view>
  18. <view class="dir-left-nowrap cross-center form-input">
  19. <view class="box-grow-0 form-label main-right">联系电话</view>
  20. <view class="box-grow-1">
  21. <input @input="applyInput"
  22. :disabled="form_status && status !== 2"
  23. data-type="mobile"
  24. placeholder-class="plugins-mch-apply-input"
  25. placeholder="必填"
  26. name="mobile"
  27. :value="form.mobile"/>
  28. </view>
  29. </view>
  30. <view class="dir-left-nowrap cross-center form-input">
  31. <view class="box-grow-0 form-label main-right">微信号</view>
  32. <view class="box-grow-1">
  33. <input @input="applyInput"
  34. :disabled="form_status && status !== 2"
  35. data-type="wechat"
  36. placeholder="请填写微信号"
  37. placeholder-class="plugins-mch-apply-input"
  38. name="wechat"
  39. :value="form.wechat"/>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="apply-com">账号信息</view>
  44. <view class="white">
  45. <view class="dir-left-nowrap cross-center form-input">
  46. <view class="box-grow-0 form-label main-right">账号</view>
  47. <view class="box-grow-1">
  48. <input @input="applyInput"
  49. :disabled="form_status && status !== 2"
  50. data-type="username"
  51. placeholder-class="plugins-mch-apply-input"
  52. placeholder="必填"
  53. name="username"
  54. :value="form.username"/>
  55. </view>
  56. </view>
  57. <view class="dir-left-nowrap cross-center form-input">
  58. <view class="box-grow-0 form-label main-right">密码</view>
  59. <view class="box-grow-1">
  60. <input @input="applyInput"
  61. :disabled="form_status && status !== 2"
  62. password
  63. data-type="password"
  64. placeholder-class="plugins-mch-apply-input"
  65. placeholder="必填"
  66. name="password"
  67. :value="form.password"/>
  68. </view>
  69. </view>
  70. <view class="dir-left-nowrap cross-center form-input">
  71. <view class="box-grow-0 form-label main-right">确认密码</view>
  72. <view class="box-grow-1">
  73. <input @input="applyInput"
  74. :disabled="form_status && status !== 2"
  75. password
  76. data-type="checkPass"
  77. placeholder-class="plugins-mch-apply-input"
  78. placeholder="必填"
  79. name="checkPass"
  80. :value="form.checkPass"/>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="apply-com">店铺信息</view>
  85. <view class="white">
  86. <view class="dir-left-nowrap cross-center form-input">
  87. <view class="box-grow-0 form-label main-right">店铺名称</view>
  88. <view class="box-grow-1">
  89. <input @input="applyInput"
  90. :disabled="form_status && status !== 2"
  91. data-type="name"
  92. placeholder-class="plugins-mch-apply-input"
  93. placeholder="必填"
  94. name="name"
  95. :value="form.name"/>
  96. </view>
  97. </view>
  98. <view class="dir-left-nowrap cross-center form-input">
  99. <view class="box-grow-0 form-label main-right">所在地区</view>
  100. <view class="box-grow-1 area-left">
  101. <app-area-picker @customevent="areaEvent"
  102. :ids="[area.province_id, area.city_id, area.district_id]"></app-area-picker>
  103. </view>
  104. </view>
  105. <view class="dir-left-nowrap cross-center form-input">
  106. <view class="box-grow-0 form-label main-right">详细地址</view>
  107. <view class="box-grow-1">
  108. <input @input="applyInput"
  109. :disabled="form_status && status !== 2"
  110. data-type="address"
  111. placeholder-class="plugins-mch-apply-input"
  112. placeholder="必填"
  113. name="address"
  114. :value="form.address"/>
  115. </view>
  116. </view>
  117. <view class="dir-left-nowrap cross-center form-input">
  118. <view class="box-grow-0 form-label main-right">客服电话</view>
  119. <view class="box-grow-1">
  120. <input @input="applyInput"
  121. :disabled="form_status && status !== 2"
  122. data-type="service_mobile"
  123. placeholder-class="plugins-mch-apply-input"
  124. placeholder="必填"
  125. name="service_mobile"
  126. :value="form.service_mobile"/>
  127. </view>
  128. </view>
  129. <view class="dir-left-nowrap cross-center form-input">
  130. <view class="box-grow-0 form-label main-right">所售类目</view>
  131. <view class="box-grow-1">
  132. <picker :disabled="form_status && status !== 2"
  133. :range="category_list" range-key="name" class="category-picker"
  134. :value="form.mch_common_cat_id" @change="categoryChange">
  135. <view class="cross-center dir-left-nowrap category-info">
  136. <view class="box-grow-1 category-select">
  137. {{form.mch_common_cat_str?form.mch_common_cat_str:`请选择`}}
  138. </view>
  139. <view class="box-grow-0 cross-center">
  140. <icon class="icon-arrow-right"></icon>
  141. </view>
  142. </view>
  143. </picker>
  144. </view>
  145. </view>
  146. </view>
  147. <block v-if="form_data && form_data.length && (setting.status === '1' || status >= 0)">
  148. <!-- 自定义表单-->
  149. <app-diy-form title="其他信息" :list="form_data" sign="mch" @input="hangleForm"
  150. @validate="validateForm"></app-diy-form>
  151. </block>
  152. <block v-if="!form_status || status === 2">
  153. <view class="dir-left-nowrap cross-center rules-box">
  154. <view v-if="rulesStatus" class="icon" @click="rulesTap(false)">
  155. <icon class="icon-true"></icon>
  156. </view>
  157. <view v-else class="icon" @click="rulesTap(true)">
  158. <icon class="icon-false"></icon>
  159. </view>
  160. <view class="block">我已阅读并同意</view>
  161. <view @click="navApplyRules" class="blue">《入驻协议》</view>
  162. </view>
  163. <view class="main-center submit-btn" v-if="status === -1 || status === 2">
  164. <app-button @click="formSubmit" height="80" width="702" font-size="32" background="#ff4544"
  165. color="#FFFFFF" round>提交
  166. </app-button>
  167. </view>
  168. </block>
  169. <view v-if="form_status" class="cross-center dir-top-nowrap main-center">
  170. <view @click="closeForm" class="result-title">查看审核结果</view>
  171. <view @click="navHome" class="result-home">返回首页</view>
  172. </view>
  173. </view>
  174. <!-- STATUS -->
  175. <block v-if="status >=0 && !form_status">
  176. <view class="dir-top-nowrap main-center cross-center">
  177. <view class="main-center form-img">
  178. <image v-if="status === 0" :src="appImg.load"></image>
  179. <image v-else-if="status === 1" :src="appImg.success"></image>
  180. <image v-else-if="status === 2" :src="appImg.error"></image>
  181. </view>
  182. <view class="status-title">
  183. <view v-if="status === 0">待审核</view>
  184. <view v-else-if="status === 1">审核通过</view>
  185. <view v-else-if="status === 2">审核失败</view>
  186. </view>
  187. <view class="status-content">
  188. <view v-if="status === 0">您的信息已提交,请耐心等待审核。</view>
  189. <block v-else-if="status === 2">
  190. <view v-if="mch.review_remark">{{mch.review_remark}}</view>
  191. <view v-else>您的信息填写不完整,请重新填写</view>
  192. </block>
  193. </view>
  194. <view v-if="status === 2" class="status-new main-center">
  195. <app-button @click="openForm" height="80" width="560" background="#FF4544" color="#FFFFFF"
  196. font-size="32" round>重新申请
  197. </app-button>
  198. </view>
  199. <view v-else class="status-submit" @click="openForm">查看提交内容</view>
  200. </view>
  201. </block>
  202. </app-layout>
  203. </template>
  204. <script>
  205. import {mapState} from 'vuex';
  206. import appAreaPicker from '../../../components/page-component/app-area-picker/app-area-picker';
  207. import appDiyForm from '../../../components/page-component/app-diy-form/app-diy-form';
  208. export default {
  209. name: "apply",
  210. components: {appAreaPicker, appDiyForm},
  211. computed: {
  212. ...mapState({
  213. appImg: state => state.mallConfig.plugin.mch.app_image,
  214. }),
  215. },
  216. data() {
  217. return {
  218. mch_id: -1,
  219. category_list: [],
  220. express_list: null,
  221. form_data: null,
  222. form_status: false,
  223. rulesStatus: false,
  224. area: {
  225. province_id: 0,
  226. city_id: 0,
  227. district_id: 0,
  228. },
  229. setting: null,
  230. status: -2,
  231. form: {
  232. realname: '',
  233. mobile: '',
  234. wechat: '',
  235. username: '',
  236. password: '',
  237. checkPass: '',
  238. address: '',
  239. name: '',
  240. service_mobile: '',
  241. mch_common_cat_str: '',
  242. mch_common_cat_id: 0,
  243. },
  244. formStatus: {
  245. errors: [],
  246. hasError: false,
  247. },
  248. submit_status: false,
  249. template_message_list: null,
  250. }
  251. },
  252. onLoad: function (options) {
  253. this.mch_id = options.mch_id;
  254. this.getCategory();
  255. },
  256. methods: {
  257. hangleForm(form_data) {
  258. this.form.form_data = form_data;
  259. },
  260. navApplyRules() {
  261. // uni.navigateTo({url: `/plugins/mch/apply_rules/apply_rules`});
  262. uni.navigateTo({
  263. url: `/pages/rules/index?url=${encodeURIComponent(this.$api.mch.setting)}&keys=${JSON.stringify(['setting', 'desc'])}`,
  264. });
  265. },
  266. navHome() {
  267. uni.navigateTo({url: `/pages/index/index`});
  268. },
  269. loadData: function () {
  270. const self = this;
  271. self.$showLoading();
  272. self.$request({
  273. url: self.$api.mch.mch_status,
  274. }).then(info => {
  275. self.$hideLoading();
  276. if (info.code === 0) {
  277. self.mch = info.data.mch;
  278. self.status = self.mch ? self.mch.review_status : -1;
  279. self.template_message_list = info.data.template_message_list;
  280. if (self.mch) {
  281. self.formInfo(self.mch.id);
  282. } else {
  283. self.getSetting();
  284. }
  285. }
  286. }).catch(e => {
  287. self.$hideLoading();
  288. })
  289. },
  290. //FUNCTION
  291. getCategory: function () {
  292. const self = this;
  293. self.$request({
  294. url: self.$api.mch.category,
  295. data: {
  296. id: self.mch_id,
  297. }
  298. }).then(info => {
  299. if (info.code === 0) {
  300. self.category_list = info.data.list;
  301. self.loadData();
  302. }
  303. });
  304. },
  305. getExpress: function () {
  306. const self = this;
  307. self.$request({
  308. url: self.$api.mch.express_list,
  309. }).then(info => {
  310. if (info.code === 0) {
  311. self.express_list = info.data.list;
  312. }
  313. });
  314. },
  315. getSetting: function () {
  316. const self = this;
  317. self.$request({
  318. url: self.$api.mch.setting,
  319. }).then(info => {
  320. self.$hideLoading();
  321. if (info.code === 0) {
  322. self.setting = info.data.setting;
  323. self.form_data = info.data.setting.form_data;
  324. }
  325. });
  326. },
  327. //INFO
  328. formInfo(mch_id) {
  329. const self = this;
  330. self.getExpress();
  331. self.$request({
  332. url: self.$api.mch.detail,
  333. data: {
  334. id: mch_id,
  335. is_review_status: 1,
  336. }
  337. }).then(info => {
  338. if (info.code === 0) {
  339. const detail = info.data.detail;
  340. let mch_common_cat_str = '';
  341. self.category_list.forEach(v => {
  342. if (v.id == detail.mch_common_cat_id)
  343. mch_common_cat_str = v.name
  344. });
  345. if (self.status === 2) {
  346. self.getSetting();
  347. }
  348. //表单处理
  349. if (self.status === 0 || self.status === 1) {
  350. let form_data = [];
  351. if (detail.form_data && detail.form_data.length) {
  352. detail.form_data.map(v => {
  353. let list = [];
  354. if (v.key === 'checkbox') {
  355. v.value = v.value ? v.value: [];
  356. v.value.map(v => {
  357. list.push({label: v});
  358. })
  359. }
  360. if (v.key === 'radio') {
  361. list.push({label: v.value});
  362. }
  363. form_data.push({
  364. key: v.key,
  365. name: v.key_name,
  366. default: v.value,
  367. is_required: v.required,
  368. img_type: v.img_type,
  369. list: list,
  370. })
  371. });
  372. }
  373. self.form_data = form_data;
  374. }
  375. self.form = {
  376. mch_id: detail.id,
  377. realname: detail.realname,
  378. mobile: detail.mobile,
  379. wechat: detail.wechat,
  380. username: detail.mchUser.username,
  381. password: '000000',
  382. checkPass: '000000',
  383. address: detail.store.address,
  384. name: detail.store.name,
  385. service_mobile: detail.store.mobile,
  386. mch_common_cat_str: mch_common_cat_str,
  387. mch_common_cat_id: detail.mch_common_cat_id,
  388. };
  389. self.area = {
  390. province_id: detail.store.province_id,
  391. city_id: detail.store.city_id,
  392. district_id: detail.store.district_id,
  393. };
  394. }
  395. });
  396. },
  397. //INPUT
  398. applyInput: function (e) {
  399. let name = e.currentTarget.dataset.type;
  400. this.form[name] = e.detail.value;
  401. },
  402. categoryChange(e) {
  403. const item = this.category_list[e.detail.value];
  404. this.form.mch_common_cat_id = item.id;
  405. this.form.mch_common_cat_str = item.name;
  406. },
  407. //地址处理
  408. areaEvent(data) {
  409. if (data) {
  410. this.area.province_id = data.province.id;
  411. this.area.city_id = data.city.id;
  412. this.area.district_id = data.district.id;
  413. }
  414. },
  415. validateForm: function (e) {
  416. this.formStatus = e;
  417. },
  418. subscribe(callback) {
  419. this.$subscribe(this.template_message_list).then(res => {
  420. callback();
  421. }).catch(res => {
  422. callback();
  423. });
  424. },
  425. //SUBMIT
  426. formSubmit: function (e) {
  427. const self = this;
  428. let form = self.form;
  429. let area = self.area;
  430. let rulesStatus = self.rulesStatus;
  431. let content = function () {
  432. if (!rulesStatus) {
  433. return '请同意入驻协议';
  434. }
  435. if (!form.realname) {
  436. return "联系人不能为空";
  437. }
  438. if (!form.mobile) {
  439. return "联系电话不能为空";
  440. }
  441. if (!form.username) {
  442. return "账号不能为空";
  443. }
  444. if (!form.password) {
  445. return "密码不能为空";
  446. }
  447. if (!form.mch_common_cat_id) {
  448. return "类目不能为空";
  449. }
  450. if (form.password !== form.checkPass) {
  451. return "密码不一致";
  452. }
  453. if (!form.name) {
  454. return "店铺名称不能为空";
  455. }
  456. if (self.formStatus.hasError) {
  457. return self.formStatus.errors[0].msg;
  458. }
  459. if (self.submit_status) {
  460. return "提交中";
  461. }
  462. return false;
  463. }();
  464. if (content) {
  465. uni.showToast({title: content, icon: 'none'});
  466. return;
  467. }
  468. self.subscribe(() => {
  469. self.$showLoading({text: `提交中`});
  470. self.submit_status = true;
  471. self.$request({
  472. url: self.$api.mch.apply,
  473. data: {
  474. id: form.mch_id ? form.mch_id : 0,
  475. realname: form.realname,
  476. mobile: form.mobile,
  477. wechat: form.wechat,
  478. username: form.username,
  479. password: form.password,
  480. name: form.name,
  481. province_id: area.province_id,
  482. city_id: area.city_id,
  483. district_id: area.district_id,
  484. mch_common_cat_id: form.mch_common_cat_id,
  485. address: form.address,
  486. service_mobile: form.service_mobile,
  487. form_data: form.form_data ? JSON.stringify(form.form_data) : JSON.stringify([]),
  488. is_update_apply: self.status === 2 ? 1 : 0,
  489. },
  490. method: 'POST',
  491. }).then(info => {
  492. self.submit_status = false;
  493. self.$hideLoading();
  494. if (info.code === 0) {
  495. self.loadData();
  496. self.form_status = false;
  497. } else {
  498. uni.showToast({title: info.msg, icon: 'none'});
  499. }
  500. }).catch(e => {
  501. self.submit_status = false;
  502. })
  503. })
  504. },
  505. rulesTap: function (status) {
  506. this.rulesStatus = status;
  507. },
  508. closeForm() {
  509. this.form_status = false;
  510. },
  511. openForm() {
  512. this.form_status = true;
  513. },
  514. }
  515. }
  516. </script>
  517. <style lang="scss">
  518. .plugins-mch-apply-input {
  519. color: #bbb;
  520. font-size: #{28rpx};
  521. }
  522. </style>
  523. <style scoped lang="scss">
  524. .apply-com {
  525. padding-top: #{30rpx};
  526. padding-left: #{24rpx};
  527. height: #{72rpx};
  528. color: #999;
  529. font-size: #{26rpx};
  530. background: #f7f7f7;
  531. width: 100%;
  532. }
  533. .white {
  534. background: #FFFFFF;
  535. .form-input {
  536. margin: 0 #{24rpx};
  537. border-bottom: 1px solid #e2e2e2;
  538. height: #{100rpx}
  539. }
  540. input {
  541. height: 100%;
  542. padding: 0 #{32rpx};
  543. color: #666666;
  544. font-size: #{28rpx};
  545. }
  546. .form-label {
  547. padding-left: #{3rpx};
  548. font-size: #{28rpx};
  549. color: #353535;
  550. min-width: #{125rpx};
  551. }
  552. > view:last-child {
  553. border-bottom: none;
  554. }
  555. .icon-arrow-right {
  556. background-image: url("../../../static/image/icon/arrow-right.png");
  557. height: #{22rpx};
  558. width: #{12rpx};
  559. background-size: 100% auto;
  560. background-repeat: no-repeat;
  561. }
  562. .area-left {
  563. padding-left: #{32rpx};
  564. text-align: right;
  565. margin-left: auto;
  566. }
  567. .category-picker {
  568. height: 100%;
  569. width: 100%;
  570. }
  571. .category-info {
  572. height: 100%;
  573. width: 100%;
  574. min-height: #{98rpx};
  575. }
  576. .category-select {
  577. font-size: #{28rpx};
  578. color: #666666;
  579. text-align: right;
  580. padding-right: #{24rpx};
  581. }
  582. }
  583. .rules-box {
  584. background: #f7f7f7;
  585. margin: #{32rpx} #{24rpx};
  586. font-size: #{28rpx};
  587. .icon {
  588. height: #{32rpx};
  589. width: #{32rpx};
  590. margin-right: #{16rpx};
  591. }
  592. .icon-true {
  593. height: #{32rpx};
  594. width: #{32rpx};
  595. background-repeat: no-repeat;
  596. background-image: url("../image/apply-ok.png");
  597. background-size: 100% 100%;
  598. }
  599. .icon-false {
  600. height: #{32rpx};
  601. width: #{32rpx};
  602. background-repeat: no-repeat;
  603. background-image: url("../image/apply-er.png");
  604. background-size: 100% 100%;
  605. }
  606. .block {
  607. color: #353535;
  608. }
  609. .blue {
  610. color: #5292ed;
  611. }
  612. }
  613. .submit-btn {
  614. margin-top: #{52rpx - 32rpx};
  615. margin-bottom: #{24rpx};
  616. }
  617. .result-title {
  618. color: #387ee8;
  619. font-size: #{28rpx};
  620. margin-top: #{32rpx};
  621. }
  622. .result-home {
  623. color: #666;
  624. font-size: #{28rpx};
  625. padding: #{24rpx};
  626. }
  627. .form-img {
  628. width: 100%;
  629. margin-top: #{150rpx};
  630. margin-bottom: #{72rpx};
  631. image {
  632. height: #{270rpx};
  633. width: #{380rpx};
  634. }
  635. }
  636. .status-title {
  637. font-size: #{36rpx};
  638. color: #666666;
  639. }
  640. .status-content {
  641. margin-top: #{24rpx};
  642. color: #666666;
  643. width: #{560rpx};
  644. view {
  645. text-align: center;
  646. }
  647. }
  648. .status-new {
  649. margin-top: #{88rpx};
  650. }
  651. .status-submit {
  652. color: #5292ed;
  653. font-size: #{28rpx};
  654. margin-top: #{66rpx};
  655. }
  656. </style>