add.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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: 28rpx;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: 28rpx;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: 28rpx;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="root+'/web/statics/img/app/common/upload.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. root:''
  111. }
  112. },
  113. computed: {
  114. ...mapState({
  115. mall: state => state.mallConfig.mall,
  116. custom_setting: state => state.mallConfig.share_setting_custom,
  117. share_setting: state => state.mallConfig.share_setting,
  118. })
  119. },
  120. components: {
  121. AppDiyForm
  122. },
  123. methods: {
  124. handleFormInput(data) {
  125. const result = [];
  126. for (let i in data) {
  127. result[i] = {
  128. key: data[i].key,
  129. label: data[i].name,
  130. value: data[i].value,
  131. required: data[i].is_required,
  132. };
  133. }
  134. this.form = result;
  135. },
  136. toRead() {
  137. this.read = !this.read
  138. },
  139. imageLoad: function (e) {
  140. var $width = e.detail.width; //获取图片真实宽度
  141. var $height = e.detail.height; //获取图片真实高度
  142. this.height = $height * (702 / $width)
  143. },
  144. subscribe() {
  145. let that = this;
  146. let read = 0;
  147. if(this.form.length > 0) {
  148. for(let item of this.form) {
  149. if(item.required == 1) {
  150. if(!item.value) {
  151. uni.showToast({
  152. title: '请填写' + item.label,
  153. icon: 'none',
  154. duration: 1000
  155. });
  156. return false
  157. }
  158. if(item.key == 'img_upload' && Array.isArray(item.value)) {
  159. for(let img of item.value) {
  160. if(!img) {
  161. uni.showToast({
  162. title: '请填写' + item.label,
  163. icon: 'none',
  164. duration: 1000
  165. });
  166. return false
  167. }
  168. }
  169. }
  170. }
  171. }
  172. }
  173. if (this.read == true) {
  174. read = 1;
  175. if (!that.name) {
  176. uni.showToast({
  177. title: '请输入真实姓名',
  178. icon: 'none',
  179. duration: 1000
  180. });
  181. } else if (!that.phone) {
  182. uni.showToast({
  183. title: '请输入手机号码',
  184. icon: 'none',
  185. duration: 1000
  186. });
  187. } else if (!(/0?(1)[0-9]{10}/.test(that.phone))) {
  188. uni.showToast({
  189. title: '请输入正确的手机号码',
  190. icon: 'none',
  191. duration: 1000
  192. });
  193. }else if (!that.wechat_num) {
  194. uni.showToast({
  195. title: '请输入微信号',
  196. icon: 'none',
  197. duration: 1000
  198. });
  199. } else if (!that.wechat_qrcode) {
  200. uni.showToast({
  201. title: '请上传微信二维码',
  202. icon: 'none',
  203. duration: 1000
  204. });
  205. } else {
  206. // let template_message = [this.template_message]
  207. this.$subscribe(this.template_message).then(res => {
  208. this.submit(read);
  209. }).catch(res => {
  210. this.submit(read);
  211. });
  212. }
  213. } else {
  214. uni.showToast({
  215. title: '请先查看分销协议并同意',
  216. icon: 'none',
  217. duration: 1000
  218. });
  219. }
  220. },
  221. submit(read) {
  222. let that = this;
  223. uni.showLoading({
  224. title: '提交中...'
  225. });
  226. let para = {
  227. name: that.name,
  228. mobile: that.phone,
  229. agree: read,
  230. wechat_num: that.wechat_num,
  231. wechat_qrcode: that.wechat_qrcode,
  232. recommend_user: that.recommend_user,
  233. }
  234. if(that.share_setting.form_status == 1) {
  235. para.form = JSON.stringify(that.form)
  236. }
  237. that.$request({
  238. url: that.$api.share.apply,
  239. data: para,
  240. method: 'post'
  241. }).then(response => {
  242. that.$store.dispatch('mallConfig/actionResetConfig');
  243. that.$hideLoading();
  244. if (response.code == 0) {
  245. uni.showToast({
  246. title: response.msg,
  247. duration: 1000
  248. });
  249. setTimeout(function() {
  250. uni.navigateBack({
  251. delta: 1
  252. })
  253. }, 500)
  254. } else {
  255. if(that.share_setting.form_status == 0 && response.msg == '请填写表单') {
  256. uni.showToast({
  257. title: '申请条件有所变化,请重新填写',
  258. icon: 'none',
  259. duration: 1000
  260. });
  261. }else {
  262. uni.showToast({
  263. title: response.msg,
  264. icon: 'none',
  265. duration: 1000
  266. });
  267. }
  268. }
  269. }).catch(e => {
  270. that.$hideLoading();
  271. uni.showToast({
  272. title: response,
  273. icon: 'none',
  274. duration: 1000
  275. });
  276. })
  277. },
  278. uploadQRode(){
  279. let _this = this;
  280. uni.chooseImage({
  281. count: 1,
  282. sizeType: ['original', 'compressed'],
  283. sourceType: ['album', 'camera'],
  284. success(res) {
  285. uni.uploadFile({
  286. url: _this.$api.upload.file,
  287. filePath: res.tempFilePaths[0],
  288. name: 'file',
  289. success(response) {
  290. _this.wechat_qrcode = JSON.parse(response.data).data.url;
  291. }
  292. });
  293. }
  294. });
  295. }
  296. },
  297. onLoad(options) {
  298. let that = this;
  299. that.root = this.$siteInfo.root;
  300. this.$showLoading({
  301. type: 'global',
  302. text: '加载中...'
  303. });
  304. if (options.template_message != null) {
  305. that.template_message = JSON.parse(options.template_message)
  306. }
  307. uni.setNavigationBarTitle({
  308. title: this.custom_setting.apply.share_apply.name ? this.custom_setting.apply.share_apply.name : this.custom_setting.apply.share_apply.default
  309. });
  310. let _this = this;
  311. this.$request({
  312. url: this.$api.user.user_info,
  313. }).then(response => {
  314. this.$hideLoading();
  315. if (response.code === 0) {
  316. _this.parent_name = response.data.identity.parent_name;
  317. if(_this.parent_name == '总店'){
  318. _this.$request({
  319. url: this.$api.share.sys_share,
  320. }).then(res => {
  321. if(res.length){
  322. _this.parent_name = `${res.name}(微信号:${res.wechat_num})`;
  323. _this.recommend_user = res.user_id;
  324. }
  325. })
  326. }
  327. }
  328. })
  329. },
  330. onShow() {
  331. this.$store.dispatch('mallConfig/actionResetConfig');
  332. }
  333. }
  334. </script>
  335. <style scoped lang="scss">
  336. .add-bg {
  337. height: #{300rpx};
  338. width: 100%;
  339. display: block;
  340. margin-bottom: #{20rpx};
  341. background-color: #f7f7f7;
  342. }
  343. .add-form {
  344. padding: 0 #{24rpx};
  345. font-size: #{30rpx};
  346. color: #353535;
  347. .add-default {
  348. background-color: #fff;
  349. border-radius: #{16rpx};
  350. padding: 0 #{10rpx} #{35rpx};
  351. margin-bottom: #{20rpx};
  352. &.add-diy-form {
  353. padding-bottom: 0;
  354. padding: #{10rpx} #{24rpx};
  355. .add-info {
  356. border-bottom: 0;
  357. padding: #{24rpx} 0;
  358. }
  359. }
  360. .add-info {
  361. width: 100%;
  362. padding: #{10rpx} #{24rpx};
  363. border-bottom: #{1rpx} solid #e2e2e2;
  364. .red-background {
  365. background-color: #ff4544;
  366. }
  367. .add-label {
  368. height: #{45rpx};
  369. line-height: #{45rpx};
  370. font-size: #{28rpx};
  371. }
  372. .add-input {
  373. height: #{75rpx};
  374. input {
  375. height: #{65rpx};
  376. padding-top: #{5rpx};
  377. }
  378. }
  379. &.share-name {
  380. height: #{90rpx};
  381. line-height: #{90rpx};
  382. padding: 0 #{10rpx};
  383. .mall-name {
  384. max-width: #{300rpx};
  385. color: #ff4544;
  386. }
  387. }
  388. .share-user {
  389. color: #666;
  390. height: #{75rpx};
  391. line-height: #{75rpx};
  392. >text {
  393. color: #ff4544;
  394. }
  395. }
  396. .read {
  397. width: #{32rpx};
  398. height: #{32rpx};
  399. float: left;
  400. margin-right: #{10rpx};
  401. image {
  402. height: 100%;
  403. width: 100%;
  404. display: block;
  405. }
  406. }
  407. }
  408. .qr-code image{
  409. width: #{200rpx};
  410. height: #{200rpx};
  411. }
  412. }
  413. }
  414. .submit {
  415. background-color: #f7f7f7;
  416. margin: 0 #{-24rpx};
  417. padding: #{24rpx};
  418. button {
  419. color: #fff;
  420. font-size: #{30rpx};
  421. font-weight: bold;
  422. height: #{80rpx};
  423. border-radius: #{40rpx};
  424. line-height: #{80rpx};
  425. }
  426. }
  427. .other {
  428. background-color: #fff;
  429. padding: 0 #{24rpx};
  430. color: #353535;
  431. font-size: #{30rpx};
  432. .end-img {
  433. width: 100%;
  434. }
  435. }
  436. .modal {
  437. position: fixed;
  438. top: 0;
  439. left: 0;
  440. right: 0;
  441. height: 100%;
  442. width: 100%;
  443. z-index: 99;
  444. background-color: rgba(0, 0, 0, 0.3);
  445. .protocol {
  446. position: relative;
  447. z-index: 99;
  448. background-color: #fff;
  449. width: 80%;
  450. border-radius: #{20rpx};
  451. margin: #{100rpx} auto;
  452. .protocol-name {
  453. height: #{100rpx};
  454. text-align: center;
  455. line-height: #{100rpx};
  456. color: #666;
  457. }
  458. .protocol-content {
  459. padding: #{10rpx} #{20rpx};
  460. height: #{720rpx};
  461. overflow: auto;
  462. color: #353535;
  463. }
  464. .read-over {
  465. text-align: center;
  466. height: #{100rpx};
  467. line-height: #{100rpx};
  468. background-color: #ff4544;
  469. color: #fff;
  470. font-size: #{30rpx};
  471. border-bottom-right-radius: #{20rpx};
  472. border-bottom-left-radius: #{20rpx};
  473. }
  474. }
  475. }
  476. </style>