add.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <app-layout>
  3. <view>
  4. <!-- 申请页面背景图片以及待审核页面背景图片 -->
  5. <image :src="custom_setting.apply.apply_head_pic" class="add-bg"></image>
  6. <!-- 未在申请分销商 -->
  7. <view class="add-form">
  8. <view class="add-default">
  9. <view class="add-info share-name dir-left-nowrap">
  10. <view>欢迎加入</view>
  11. <view class="mall-name t-omit">{{mall.name}}</view>
  12. <view>,请填写申请信息</view>
  13. </view>
  14. <view class="add-info">
  15. <view class="add-label">邀请人</view>
  16. <view class="share-user">
  17. <text >{{parent_name}}</text>(请核对)</view>
  18. </view>
  19. <view class="add-info">
  20. <view class="add-label">
  21. <text style="color: #ff4544">*</text>姓名
  22. </view>
  23. <view class="add-input">
  24. <input v-model="name" placeholder="请填写真实姓名" placeholder-style="font-size: 20rpx;color: #cdcdcd" />
  25. </view>
  26. </view>
  27. <view class="add-info">
  28. <view class="add-label">
  29. <text style="color: #ff4544">*</text>手机号码</view>
  30. <view class="add-input">
  31. <input v-model="phone" type="number" placeholder="请填写手机号码" placeholder-style ="font-size: 20rpx;color: #cdcdcd" />
  32. </view>
  33. </view>
  34. <view class="add-info">
  35. <view class="add-label">
  36. <text style="color: #ff4544">*</text>微信号
  37. </view>
  38. <view class="add-input">
  39. <input v-model="wechat_num" placeholder="微信号" placeholder-style="font-size: 20rpx;color: #cdcdcd" />
  40. </view>
  41. </view>
  42. <view class="add-info">
  43. <view class="add-label">
  44. <text style="color: #ff4544">*</text>微信二维码
  45. </view>
  46. <view @click="uploadQRode" class="qr-code">
  47. <block v-if="!wechat_qrcode"><image src="./../../../static/image/image.png"></image></block>
  48. <block v-else><image :src="wechat_qrcode"></image></block>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="add-default add-diy-form" v-if="share_setting.form_status == 1">
  53. <app-diy-form :datePadding="0" :itemHeight="66" :showRequiredIcon="true" @input="handleFormInput" labelPosition="top" :list="share_setting.form" :labelFs28="true"></app-diy-form>
  54. </view>
  55. <view class="add-default add-diy-form">
  56. <view class="add-info" style="font-size:13px;">
  57. <view class="read" @click="toRead">
  58. <image src="/static/image/icon/icon-uncheck.png" v-if="read == false"></image>
  59. <image :class="[`red-background`]" src="/static/image/icon/icon-checkbox-checked.png" v-else></image>
  60. </view>
  61. 我已经阅读并了解
  62. <text style="color:#014c8c" @click="protocol = true">【{{custom_setting.apply.share_apply_pact.name ? custom_setting.apply.share_apply_pact.name : custom_setting.apply.share_apply_pact.default}}】</text>
  63. </view>
  64. </view>
  65. <view class="submit">
  66. <view @click="subscribe">
  67. <button :style="{'background-color':`${custom_setting.apply.apply_btn_background}`,'border-radius':`${custom_setting.apply.apply_btn_round}`,'color':`${custom_setting.apply.apply_btn_color}`}">{{custom_setting.apply.apply_btn_title ? custom_setting.apply.apply_btn_title : '申请成为分销商'}}</button>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 特权 -->
  72. <view class="other">
  73. <image @load="imageLoad" :style="{'height':`${height}rpx`}" class="end-img" :src="custom_setting.apply.apply_end_pic"></image>
  74. </view>
  75. <!-- 分销协议(modal模式) -->
  76. <view class="modal" v-if="protocol">
  77. <view class="protocol">
  78. <view class="protocol-name">{{custom_setting.apply.share_apply_pact.name ? custom_setting.apply.share_apply_pact.name : custom_setting.apply.share_apply_pact.default}}</view>
  79. <view class="protocol-content">
  80. <text>{{share_setting.agree}}</text>
  81. </view>
  82. <view @click="protocol=false;read=true">
  83. <view class="read-over">我已阅读</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </app-layout>
  89. </template>
  90. <script>
  91. import { mapState } from "vuex";
  92. import AppDiyForm from "../../../components/page-component/app-diy-form/app-diy-form";
  93. import uploadFile from "../../../core/upload";
  94. export default {
  95. data() {
  96. return {
  97. status: null,
  98. mallName: '',
  99. name: '',
  100. phone: '',
  101. parent_name: '',
  102. height: 0,
  103. form: {},
  104. template_message: [],
  105. read: false,
  106. protocol: false,
  107. wechat_num: '',
  108. wechat_qrcode: '',
  109. recommend_user: 0,
  110. }
  111. },
  112. computed: {
  113. ...mapState({
  114. mall: state => state.mallConfig.mall,
  115. custom_setting: state => state.mallConfig.share_setting_custom,
  116. share_setting: state => state.mallConfig.share_setting,
  117. })
  118. },
  119. components: {
  120. AppDiyForm
  121. },
  122. methods: {
  123. handleFormInput(data) {
  124. const result = [];
  125. for (let i in data) {
  126. result[i] = {
  127. key: data[i].key,
  128. label: data[i].name,
  129. value: data[i].value,
  130. required: data[i].is_required,
  131. };
  132. }
  133. this.form = result;
  134. },
  135. toRead() {
  136. this.read = !this.read
  137. },
  138. imageLoad: function (e) {
  139. var $width = e.detail.width; //获取图片真实宽度
  140. var $height = e.detail.height; //获取图片真实高度
  141. this.height = $height * (702 / $width)
  142. },
  143. subscribe() {
  144. let that = this;
  145. let read = 0;
  146. if(this.form.length > 0) {
  147. for(let item of this.form) {
  148. if(item.required == 1) {
  149. if(!item.value) {
  150. uni.showToast({
  151. title: '请填写' + item.label,
  152. icon: 'none',
  153. duration: 1000
  154. });
  155. return false
  156. }
  157. if(item.key == 'img_upload' && Array.isArray(item.value)) {
  158. for(let img of item.value) {
  159. if(!img) {
  160. uni.showToast({
  161. title: '请填写' + item.label,
  162. icon: 'none',
  163. duration: 1000
  164. });
  165. return false
  166. }
  167. }
  168. }
  169. }
  170. }
  171. }
  172. if (this.read == true) {
  173. read = 1;
  174. if (!that.name) {
  175. uni.showToast({
  176. title: '请输入真实姓名',
  177. icon: 'none',
  178. duration: 1000
  179. });
  180. } else if (!that.phone) {
  181. uni.showToast({
  182. title: '请输入手机号码',
  183. icon: 'none',
  184. duration: 1000
  185. });
  186. } else if (!(/0?(1)[0-9]{10}/.test(that.phone))) {
  187. uni.showToast({
  188. title: '请输入正确的手机号码',
  189. icon: 'none',
  190. duration: 1000
  191. });
  192. }else if (!that.wechat_num) {
  193. uni.showToast({
  194. title: '请输入微信号',
  195. icon: 'none',
  196. duration: 1000
  197. });
  198. } else if (!that.wechat_qrcode) {
  199. uni.showToast({
  200. title: '请上传微信二维码',
  201. icon: 'none',
  202. duration: 1000
  203. });
  204. } else {
  205. // let template_message = [this.template_message]
  206. this.$subscribe(this.template_message).then(res => {
  207. this.submit(read);
  208. }).catch(res => {
  209. this.submit(read);
  210. });
  211. }
  212. } else {
  213. uni.showToast({
  214. title: '请先查看分销协议并同意',
  215. icon: 'none',
  216. duration: 1000
  217. });
  218. }
  219. },
  220. submit(read) {
  221. let that = this;
  222. uni.showLoading({
  223. title: '提交中...'
  224. });
  225. let para = {
  226. name: that.name,
  227. mobile: that.phone,
  228. agree: read,
  229. wechat_num: that.wechat_num,
  230. wechat_qrcode: that.wechat_qrcode,
  231. recommend_user: that.recommend_user,
  232. }
  233. if(that.share_setting.form_status == 1) {
  234. para.form = JSON.stringify(that.form)
  235. }
  236. that.$request({
  237. url: that.$api.share.apply,
  238. data: para,
  239. method: 'post'
  240. }).then(response => {
  241. that.$store.dispatch('mallConfig/actionResetConfig');
  242. that.$hideLoading();
  243. if (response.code == 0) {
  244. uni.showToast({
  245. title: response.msg,
  246. duration: 1000
  247. });
  248. setTimeout(function() {
  249. uni.navigateBack({
  250. delta: 1
  251. })
  252. }, 500)
  253. } else {
  254. if(that.share_setting.form_status == 0 && response.msg == '请填写表单') {
  255. uni.showToast({
  256. title: '申请条件有所变化,请重新填写',
  257. icon: 'none',
  258. duration: 1000
  259. });
  260. }else {
  261. uni.showToast({
  262. title: response.msg,
  263. icon: 'none',
  264. duration: 1000
  265. });
  266. }
  267. }
  268. }).catch(e => {
  269. that.$hideLoading();
  270. uni.showToast({
  271. title: response,
  272. icon: 'none',
  273. duration: 1000
  274. });
  275. })
  276. },
  277. uploadQRode(){
  278. let _this = this;
  279. uni.chooseImage({
  280. count: 1,
  281. sizeType: ['original', 'compressed'],
  282. sourceType: ['album', 'camera'],
  283. success(res) {
  284. uni.uploadFile({
  285. url: _this.$api.upload.file,
  286. filePath: res.tempFilePaths[0],
  287. name: 'file',
  288. success(response) {
  289. _this.wechat_qrcode = JSON.parse(response.data).data.url;
  290. }
  291. });
  292. }
  293. });
  294. }
  295. },
  296. onLoad(options) {
  297. let that = this;
  298. this.$showLoading({
  299. type: 'global',
  300. text: '加载中...'
  301. });
  302. if (options.template_message != null) {
  303. that.template_message = JSON.parse(options.template_message)
  304. }
  305. uni.setNavigationBarTitle({
  306. title: this.custom_setting.apply.share_apply.name ? this.custom_setting.apply.share_apply.name : this.custom_setting.apply.share_apply.default
  307. });
  308. let _this = this;
  309. this.$request({
  310. url: this.$api.user.user_info,
  311. }).then(response => {
  312. this.$hideLoading();
  313. if (response.code === 0) {
  314. _this.parent_name = response.data.identity.parent_name;
  315. if(_this.parent_name == '总店'){
  316. _this.$request({
  317. url: this.$api.share.sys_share,
  318. }).then(res => {
  319. if(res.length){
  320. _this.parent_name = `${res.name}(微信号:${res.wechat_num})`;
  321. _this.recommend_user = res.user_id;
  322. }
  323. })
  324. }
  325. }
  326. })
  327. },
  328. onShow() {
  329. this.$store.dispatch('mallConfig/actionResetConfig');
  330. }
  331. }
  332. </script>
  333. <style scoped lang="scss">
  334. .add-bg {
  335. height: #{300rpx};
  336. width: 100%;
  337. display: block;
  338. margin-bottom: #{20rpx};
  339. background-color: #f7f7f7;
  340. }
  341. .add-form {
  342. padding: 0 #{24rpx};
  343. font-size: #{30rpx};
  344. color: #353535;
  345. .add-default {
  346. background-color: #fff;
  347. border-radius: #{16rpx};
  348. padding: 0 #{10rpx} #{35rpx};
  349. margin-bottom: #{20rpx};
  350. &.add-diy-form {
  351. padding-bottom: 0;
  352. padding: #{10rpx} #{24rpx};
  353. .add-info {
  354. border-bottom: 0;
  355. padding: #{24rpx} 0;
  356. }
  357. }
  358. .add-info {
  359. width: 100%;
  360. padding: #{10rpx} #{24rpx};
  361. border-bottom: #{1rpx} solid #e2e2e2;
  362. .red-background {
  363. background-color: #ff4544;
  364. }
  365. .add-label {
  366. height: #{45rpx};
  367. line-height: #{45rpx};
  368. font-size: #{28rpx};
  369. }
  370. .add-input {
  371. height: #{75rpx};
  372. input {
  373. height: #{65rpx};
  374. padding-top: #{5rpx};
  375. }
  376. }
  377. &.share-name {
  378. height: #{90rpx};
  379. line-height: #{90rpx};
  380. padding: 0 #{10rpx};
  381. .mall-name {
  382. max-width: #{300rpx};
  383. color: #ff4544;
  384. }
  385. }
  386. .share-user {
  387. color: #666;
  388. height: #{75rpx};
  389. line-height: #{75rpx};
  390. >text {
  391. color: #ff4544;
  392. }
  393. }
  394. .read {
  395. width: #{32rpx};
  396. height: #{32rpx};
  397. float: left;
  398. margin-right: #{10rpx};
  399. image {
  400. height: 100%;
  401. width: 100%;
  402. display: block;
  403. }
  404. }
  405. }
  406. .qr-code image{
  407. width: #{200rpx};
  408. height: #{200rpx};
  409. }
  410. }
  411. }
  412. .submit {
  413. background-color: #f7f7f7;
  414. margin: 0 #{-24rpx};
  415. padding: #{24rpx};
  416. button {
  417. color: #fff;
  418. font-size: #{30rpx};
  419. font-weight: bold;
  420. height: #{80rpx};
  421. border-radius: #{40rpx};
  422. line-height: #{80rpx};
  423. }
  424. }
  425. .other {
  426. background-color: #fff;
  427. padding: 0 #{24rpx};
  428. color: #353535;
  429. font-size: #{30rpx};
  430. .end-img {
  431. width: 100%;
  432. }
  433. }
  434. .modal {
  435. position: fixed;
  436. top: 0;
  437. left: 0;
  438. right: 0;
  439. height: 100%;
  440. width: 100%;
  441. z-index: 99;
  442. background-color: rgba(0, 0, 0, 0.3);
  443. .protocol {
  444. position: relative;
  445. z-index: 99;
  446. background-color: #fff;
  447. width: 80%;
  448. border-radius: #{20rpx};
  449. margin: #{100rpx} auto;
  450. .protocol-name {
  451. height: #{100rpx};
  452. text-align: center;
  453. line-height: #{100rpx};
  454. color: #666;
  455. }
  456. .protocol-content {
  457. padding: #{10rpx} #{20rpx};
  458. height: #{720rpx};
  459. overflow: auto;
  460. color: #353535;
  461. }
  462. .read-over {
  463. text-align: center;
  464. height: #{100rpx};
  465. line-height: #{100rpx};
  466. background-color: #ff4544;
  467. color: #fff;
  468. font-size: #{30rpx};
  469. border-bottom-right-radius: #{20rpx};
  470. border-bottom-left-radius: #{20rpx};
  471. }
  472. }
  473. }
  474. </style>