add.vue 15 KB

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