apply.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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" type></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. <view class="icon-true" type></view>
  156. </view>
  157. <view v-else class="icon" @click="rulesTap(true)">
  158. <view class="icon-false" type></view>
  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: {},
  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(options) { this.$commonLoad.onload(options);
  253. this.mch_id = options.mch_id;
  254. this.getCategory();
  255. },
  256. methods: {
  257. hangleForm({data}) {
  258. this.form.form_data = 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. if (self.mch.status == 1) {
  283. //缓存
  284. this.$storage.setStorageSync("MCH2019", info.data);
  285. }
  286. } else {
  287. self.getSetting();
  288. }
  289. }
  290. }).catch(e => {
  291. self.$hideLoading();
  292. })
  293. },
  294. //FUNCTION
  295. getCategory: function () {
  296. const self = this;
  297. self.$request({
  298. url: self.$api.mch.category,
  299. data: {
  300. id: self.mch_id,
  301. }
  302. }).then(info => {
  303. if (info.code === 0) {
  304. self.category_list = info.data.list;
  305. self.loadData();
  306. }
  307. });
  308. },
  309. getExpress: function () {
  310. const self = this;
  311. self.$request({
  312. url: self.$api.mch.express_list,
  313. }).then(info => {
  314. if (info.code === 0) {
  315. self.express_list = info.data.list;
  316. }
  317. });
  318. },
  319. getSetting: function () {
  320. const self = this;
  321. self.$request({
  322. url: self.$api.mch.setting,
  323. }).then(info => {
  324. self.$hideLoading();
  325. if (info.code === 0) {
  326. self.setting = info.data.setting;
  327. self.form_data = info.data.setting.form_data;
  328. }
  329. });
  330. },
  331. //INFO
  332. formInfo(mch_id) {
  333. const self = this;
  334. self.getExpress();
  335. self.$request({
  336. url: self.$api.mch.detail,
  337. data: {
  338. id: mch_id,
  339. is_review_status: 1,
  340. }
  341. }).then(info => {
  342. if (info.code === 0) {
  343. const detail = info.data.detail;
  344. let mch_common_cat_str = '';
  345. self.category_list.forEach(v => {
  346. if (v.id == detail.mch_common_cat_id)
  347. mch_common_cat_str = v.name
  348. });
  349. if (self.status === 2) {
  350. self.getSetting();
  351. }
  352. //表单处理
  353. if (self.status === 0 || self.status === 1) {
  354. let form_data = [];
  355. if (detail.form_data && detail.form_data.length) {
  356. detail.form_data.map(v => {
  357. let list = [];
  358. if (v.key === 'checkbox') {
  359. v.value = v.value ? v.value: [];
  360. v.value.map(v => {
  361. list.push({label: v});
  362. })
  363. }
  364. if (v.key === 'radio') {
  365. list.push({label: v.value});
  366. }
  367. form_data.push({
  368. key: v.key,
  369. name: v.key_name,
  370. default: v.value,
  371. is_required: v.required,
  372. img_type: v.img_type,
  373. list: list,
  374. })
  375. });
  376. }
  377. self.form_data = form_data;
  378. }
  379. self.form = {
  380. mch_id: detail.id,
  381. realname: detail.realname,
  382. mobile: detail.mobile,
  383. wechat: detail.wechat,
  384. username: detail.mchUser.username,
  385. password: '000000',
  386. checkPass: '000000',
  387. address: detail.store.address,
  388. name: detail.store.name,
  389. service_mobile: detail.store.mobile,
  390. mch_common_cat_str: mch_common_cat_str,
  391. mch_common_cat_id: detail.mch_common_cat_id,
  392. };
  393. self.area = {
  394. province_id: detail.store.province_id,
  395. city_id: detail.store.city_id,
  396. district_id: detail.store.district_id,
  397. };
  398. }
  399. });
  400. },
  401. //INPUT
  402. applyInput: function (e) {
  403. let name = e.currentTarget.dataset.type;
  404. this.form[name] = e.detail.value;
  405. },
  406. categoryChange(e) {
  407. const item = this.category_list[e.detail.value];
  408. this.form.mch_common_cat_id = item.id;
  409. this.form.mch_common_cat_str = item.name;
  410. },
  411. //地址处理
  412. areaEvent(data) {
  413. if (data) {
  414. this.area.province_id = data.province.id;
  415. this.area.city_id = data.city.id;
  416. this.area.district_id = data.district.id;
  417. }
  418. },
  419. validateForm: function ({result}) {
  420. this.formStatus = result;
  421. },
  422. subscribe(callback) {
  423. this.$subscribe(this.template_message_list).then(() => {
  424. callback();
  425. }).catch(() => {
  426. callback();
  427. });
  428. },
  429. //SUBMIT
  430. formSubmit: function () {
  431. const self = this;
  432. let form = self.form;
  433. let area = self.area;
  434. let rulesStatus = self.rulesStatus;
  435. let content = function () {
  436. if (!rulesStatus) {
  437. return '请同意入驻协议';
  438. }
  439. if (!form.realname) {
  440. return "联系人不能为空";
  441. }
  442. if (!form.mobile) {
  443. return "联系电话不能为空";
  444. }
  445. if (!form.username) {
  446. return "账号不能为空";
  447. }
  448. if (!form.password) {
  449. return "密码不能为空";
  450. }
  451. if (!form.mch_common_cat_id) {
  452. return "类目不能为空";
  453. }
  454. if (form.password !== form.checkPass) {
  455. return "密码不一致";
  456. }
  457. if (!form.name) {
  458. return "店铺名称不能为空";
  459. }
  460. if (self.formStatus.hasError) {
  461. return self.formStatus.errors[0].msg;
  462. }
  463. if (self.submit_status) {
  464. return "提交中";
  465. }
  466. return false;
  467. }();
  468. if (content) {
  469. uni.showToast({title: content, icon: 'none'});
  470. return;
  471. }
  472. self.subscribe(() => {
  473. self.$showLoading({text: `提交中`});
  474. self.submit_status = true;
  475. self.$request({
  476. url: self.$api.mch.apply,
  477. data: {
  478. id: form.mch_id ? form.mch_id : 0,
  479. realname: form.realname,
  480. mobile: form.mobile,
  481. wechat: form.wechat,
  482. username: form.username,
  483. password: form.password,
  484. name: form.name,
  485. province_id: area.province_id,
  486. city_id: area.city_id,
  487. district_id: area.district_id,
  488. mch_common_cat_id: form.mch_common_cat_id,
  489. address: form.address,
  490. service_mobile: form.service_mobile,
  491. form_data: form.form_data ? JSON.stringify(form.form_data) : JSON.stringify([]),
  492. is_update_apply: self.status === 2 ? 1 : 0,
  493. },
  494. method: 'POST',
  495. }).then(info => {
  496. self.submit_status = false;
  497. self.$hideLoading();
  498. if (info.code === 0) {
  499. self.loadData();
  500. self.form_status = false;
  501. } else {
  502. uni.showToast({title: info.msg, icon: 'none'});
  503. }
  504. }).catch(e => {
  505. self.submit_status = false;
  506. })
  507. })
  508. },
  509. rulesTap: function (status) {
  510. this.rulesStatus = status;
  511. },
  512. closeForm() {
  513. this.form_status = false;
  514. },
  515. openForm() {
  516. this.form_status = true;
  517. },
  518. }
  519. }
  520. </script>
  521. <style lang="scss">
  522. .plugins-mch-apply-input {
  523. color: #bbb;
  524. font-size: #{28rpx};
  525. }
  526. </style>
  527. <style scoped lang="scss">
  528. .apply-com {
  529. padding-top: #{30rpx};
  530. padding-left: #{24rpx};
  531. height: #{72rpx};
  532. color: #999;
  533. font-size: #{26rpx};
  534. background: #f7f7f7;
  535. width: 100%;
  536. }
  537. .white {
  538. background: #FFFFFF;
  539. .form-input {
  540. margin: 0 #{24rpx};
  541. border-bottom: 1px solid #e2e2e2;
  542. height: #{100rpx}
  543. }
  544. input {
  545. height: 100%;
  546. padding: 0 #{32rpx};
  547. color: #666666;
  548. font-size: #{28rpx};
  549. }
  550. .form-label {
  551. padding-left: #{3rpx};
  552. font-size: #{28rpx};
  553. color: #353535;
  554. min-width: #{125rpx};
  555. }
  556. > view:last-child {
  557. border-bottom: none;
  558. }
  559. .icon-arrow-right {
  560. background-image: url("../../../static/image/icon/arrow-right.png");
  561. height: #{22rpx};
  562. width: #{12rpx};
  563. background-size: 100% auto;
  564. background-repeat: no-repeat;
  565. }
  566. .area-left {
  567. padding-left: #{32rpx};
  568. text-align: right;
  569. margin-left: auto;
  570. }
  571. .category-picker {
  572. height: 100%;
  573. width: 100%;
  574. }
  575. .category-info {
  576. height: 100%;
  577. width: 100%;
  578. min-height: #{98rpx};
  579. }
  580. .category-select {
  581. font-size: #{28rpx};
  582. color: #666666;
  583. text-align: right;
  584. padding-right: #{24rpx};
  585. }
  586. }
  587. .rules-box {
  588. background: #f7f7f7;
  589. margin: #{32rpx} #{24rpx};
  590. font-size: #{28rpx};
  591. .icon {
  592. height: #{32rpx};
  593. width: #{32rpx};
  594. margin-right: #{16rpx};
  595. }
  596. .icon-true {
  597. height: #{32rpx};
  598. width: #{32rpx};
  599. background-repeat: no-repeat;
  600. background-image: url("../image/apply-ok.png");
  601. background-size: 100% 100%;
  602. }
  603. .icon-false {
  604. height: #{32rpx};
  605. width: #{32rpx};
  606. background-repeat: no-repeat;
  607. background-image: url("../image/apply-er.png");
  608. background-size: 100% 100%;
  609. }
  610. .block {
  611. color: #353535;
  612. }
  613. .blue {
  614. color: #5292ed;
  615. }
  616. }
  617. .submit-btn {
  618. margin-top: #{52rpx - 32rpx};
  619. margin-bottom: #{24rpx};
  620. }
  621. .result-title {
  622. color: #387ee8;
  623. font-size: #{28rpx};
  624. margin-top: #{32rpx};
  625. }
  626. .result-home {
  627. color: #666;
  628. font-size: #{28rpx};
  629. padding: #{24rpx};
  630. }
  631. .form-img {
  632. width: 100%;
  633. margin-top: #{150rpx};
  634. margin-bottom: #{72rpx};
  635. image {
  636. height: #{270rpx};
  637. width: #{380rpx};
  638. }
  639. }
  640. .status-title {
  641. font-size: #{36rpx};
  642. color: #666666;
  643. }
  644. .status-content {
  645. margin-top: #{24rpx};
  646. color: #666666;
  647. width: #{560rpx};
  648. view {
  649. text-align: center;
  650. }
  651. }
  652. .status-new {
  653. margin-top: #{88rpx};
  654. }
  655. .status-submit {
  656. color: #5292ed;
  657. font-size: #{28rpx};
  658. margin-top: #{66rpx};
  659. }
  660. </style>