apply.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view>
  3. <!--promote/apply/apply.wxml-->
  4. <view v-if="isShowPage&&isno==false">
  5. <view class="topimg">
  6. <image src="/promote/static/promote/images/sqimg.png" mode="widthFix"></image>
  7. </view>
  8. <view class="cen" v-if="showform2">
  9. <image :src="picUrlss+'sqimg2.png'"></image>
  10. <view class="tiaojian">您的申请正在审核中~</view>
  11. </view>
  12. <view class="cen" v-if="!showform">
  13. <image :src="picUrlss+'sqimg2.png'"></image>
  14. <view class="tiaojian">您还未达到开通条件哦~</view>
  15. <view class="info">{{info1}}<text>{{info3}}</text>{{info2}}<text>{{info4}}</text></view>
  16. <!-- <view class="info">成为分销商需要购买"<text>XXXXXXXXXXXXXXXX</text>"产品,您当前还未完成购买!</view> -->
  17. <view class="btn gray">立即申请</view>
  18. </view>
  19. <view class="cen" v-if="msg!=''">
  20. <!-- <image :src="picUrlss+'sqimg2.png'"></image> -->
  21. <view class="tiaojian">{{msg}}</view>
  22. </view>
  23. <view class="cen2" v-if="showform && !showform2">
  24. <form @submit="formSubmit">
  25. <view class="form">
  26. <view class="sex ipt" v-if="show">姓名<input placeholder="输入申请人姓名" name="title" :value="title"
  27. placeholder-class="placeholder" class v-if="show"></input></view>
  28. <view class="sex ipt" v-if="show3">身份证号<input
  29. :placeholder="data.cardNo!=null?data.cardNo:'输入申请人身份证号'" name="idCard"
  30. placeholder-class="placeholder" class v-if="show3"
  31. :value="data.cardNo!=null?data.cardNo:''"></input></view>
  32. <view class="sex ipt" v-if="show2">手机号码
  33. <view class="phone dflex" v-if="show2">
  34. <input placeholder="输入手机号" name="phone" :value="phone" :disabled="phone"
  35. placeholder-class="placeholder" v-if="phone"></input>
  36. <button open-type="getPhoneNumber" v-if="!phone" @getphonenumber="getphonenumber"
  37. class="phone-btn dflex">
  38. <image src="/static/pages/images/wxico.png"></image>微信授权
  39. </button>
  40. </view>
  41. </view>
  42. <view class="sex ipt" v-if="show4">推荐人<view class=" dflex" v-if="show4">
  43. <block v-if="data.pid!=null && data.pid!=0">
  44. <input :value="data.pname" disabled placeholder-class="placeholder" class></input>
  45. <input :placeholder="data.pid" name="distriUserPhone" :value="data.pid"
  46. placeholder-class="placeholder" class=" show"></input>
  47. </block>
  48. <input v-else placeholder="输入推荐人手机号" name="distriUserPhone" :value="data.pname"
  49. placeholder-class="placeholder"></input>
  50. </view>
  51. </view>
  52. <view v-if="show5" class="ipt">
  53. <picker mode="date" :value="data.birthday!=null?data.birthday:date" start="1930-01-01"
  54. end="2010-11-01" @change="bindDateChange">
  55. <view class="picker">
  56. <text>生日 </text><text
  57. style="color:black">{{data.birthday!=null?data.birthday:date}}</text>
  58. </view>
  59. </picker>
  60. </view>
  61. <view class="sex ipt" v-if="show6">性别<radio-group @change="radioChange">
  62. <radio v-for="(item, index) in item" :key="index" :value="item.value"
  63. :checked="item.checked" name="sex" class="rad">{{item.title}}</radio>
  64. </radio-group>
  65. </view>
  66. </view>
  67. <button class="btn mbglinear" :disabled="!buttonstyle"
  68. form-type="submit">{{distributionApply!='0' ?'立即申请':'完善信息'}}</button>
  69. </form>
  70. <view class="tip">重要提示:请务必输入您的真实信息</view>
  71. </view>
  72. </view>
  73. <view v-if="isno==true">
  74. <view class="cen">
  75. <image :src="picUrlss+'sqimg2.png'"></image>
  76. <view class="tiaojian">等待管理员设置开通!</view>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. // promote/apply/apply.js
  83. // promote/team/team.js
  84. const app = getApp();
  85. const req = require("../../utils/request.js");
  86. export default {
  87. data() {
  88. return {
  89. picUrlss: req.public.picUrls,
  90. isShowPage: false,
  91. showform: false,
  92. buttonstyle: false,
  93. isshow: 0,
  94. showphone: true,
  95. disablephone: false,
  96. distriUserPhone: '',
  97. distributionNeedParam: '',
  98. distributionIsExamine: '',
  99. butstyle: true,
  100. msg: '',
  101. title: '',
  102. phone: '',
  103. info1: '',
  104. info2: '',
  105. info3: '',
  106. info4: '',
  107. distributionApply: '',
  108. isDistriUser: '',
  109. showform2: false,
  110. show: false,
  111. item: [{
  112. title: '男',
  113. value: '1'
  114. }, {
  115. title: '女',
  116. value: '2'
  117. }],
  118. sex: '',
  119. pid: '',
  120. date: '',
  121. isno: false,
  122. data: "",
  123. show2: false,
  124. show3: false,
  125. show4: false,
  126. show5: false,
  127. show6: false
  128. };
  129. },
  130. components: {},
  131. props: {},
  132. /**
  133. * 生命周期函数--监听页面加载
  134. */
  135. onLoad: function(options) {
  136. // console.info(options);
  137. // if(options.type==2){
  138. // this.setData({
  139. // showform: false,
  140. // buttonstyle:false
  141. // });
  142. // }
  143. this.getmyinfo();
  144. let _ts = this;
  145. app.globalData.getCheckSessoin(json => {
  146. _ts.sessionKey = json.session_key;
  147. });
  148. },
  149. methods: {
  150. getmyinfo: function() {
  151. let that = this;
  152. req.getRequest('/api/user/info', {}, data => {
  153. // console.log(data);
  154. this.setData({
  155. isDistriUser: data.isDistriUser,
  156. pid: data.pid
  157. });
  158. if (data && data.mobile) {
  159. this.setData({
  160. phone: data.mobile
  161. });
  162. }
  163. if (data && data.pid) {
  164. this.setData({
  165. distriUserPhone: data.distriUserPhone
  166. });
  167. }
  168. if (data && data.gender) {
  169. let res = {};
  170. let items = this.item;
  171. for (let i = 0, len = items.length; i < len; ++i) {
  172. // console.log(items[i].value, data.gender);
  173. if (items[i].value == data.gender) {
  174. // items[i].checked = items[i].value === data.gender
  175. res['item[' + i + '].checked'] = true;
  176. that.setData(res);
  177. }
  178. }
  179. }
  180. this.setData({
  181. title: data.nickName,
  182. data: data
  183. });
  184. this.getdistri();
  185. });
  186. },
  187. getdistri() {
  188. req.postRequest('/api/distribution/config', {}, data => {
  189. // console.log(data.distributionApply + "==========================================");
  190. if (this.isDistriUser == 2 || data.distributionApply == 0) {
  191. uni.redirectTo({
  192. url: '/promote/team/team'
  193. });
  194. }
  195. if (this.isDistriUser == 1) {
  196. // wx.hideLoading();
  197. this.setData({
  198. isShowPage: true,
  199. showform2: true,
  200. showform: true
  201. });
  202. }
  203. if ((this.isDistriUser != 1 || this.isDistriUser != 2) && data.distributionApply != 0) {
  204. this.getDistribution(data);
  205. }
  206. });
  207. },
  208. getDistribution(data) {
  209. // wx.hideLoading();
  210. // console.log(data);
  211. /**
  212. * 判断请求回来的data是不是null的 如果是就是管理员还没配置
  213. */
  214. if (data == null) {
  215. this.setData({
  216. isno: true
  217. });
  218. } //判断分销商条件
  219. if (data.distributionType == "1") {
  220. this.setData({
  221. isShowPage: true,
  222. info1: "成为分销商需要购物满",
  223. info2: ",您当前已购物",
  224. info3: data.distributionValue + "元",
  225. info4: data.userValue == null ? 0 + "元" : data.userValue + "元"
  226. });
  227. } else if (data.distributionType == "2") {
  228. this.setData({
  229. isShowPage: true,
  230. info1: "成为分销商需要购物满",
  231. info2: ",您当前已购物",
  232. info3: data.distributionValue + "个订单",
  233. info4: data.userValue == null ? 0 + "个订单" : data.userValue + "个订单"
  234. });
  235. } else if (data.distributionType == "4") {
  236. this.setData({
  237. isShowPage: true,
  238. info1: "成为分销商需要推荐会员数量",
  239. info2: ",您当前推荐会员数量",
  240. info3: data.distributionValue + "人",
  241. info4: data.userValue == null ? 0 + "人" : data.userValue + "人"
  242. });
  243. }
  244. if (data.distributionType == "0") {
  245. this.setData({
  246. isShowPage: true,
  247. showform: true,
  248. buttonstyle: true,
  249. butstyle: false,
  250. distributionNeedParam: data.distributionNeedParam,
  251. distributionApply: data.distributionApply
  252. }); // if (data.distributionNeedParam == "0") {
  253. // console.log('无需填写值自动去申请分销');
  254. // this.submitApplymap({});
  255. // }
  256. } else if (data.distributionType == "1" || data.distributionType == "2" || data.distributionType == "4") {
  257. if (data.userValue != null && Number(data.userValue) >= Number(data.distributionValue)) {
  258. this.setData({
  259. isShowPage: true,
  260. showform: true,
  261. buttonstyle: true,
  262. butstyle: true,
  263. distributionApply: data.distributionApply,
  264. distributionIsExamine: data.distributionIsExamine,
  265. distributionNeedParam: data.distributionNeedParam
  266. });
  267. }
  268. } else if (data.distributionType == "3") {
  269. if (data.userValue != null) {
  270. var arr = data.distributionValue.split(",");
  271. var myarr = data.userValue.split(",");
  272. if (myarr.every(val => arr.includes(val))) {
  273. this.setData({
  274. isShowPage: true,
  275. showform: true,
  276. buttonstyle: true
  277. });
  278. }
  279. }
  280. }
  281. if (true) {
  282. let needparam = data.distributionNeedParam;
  283. // console.log(needparam);
  284. if (needparam.indexOf('1') != -1) {
  285. this.setData({
  286. show: true
  287. });
  288. }
  289. if (needparam.indexOf('2') != -1) {
  290. this.setData({
  291. show2: true
  292. });
  293. }
  294. if (needparam.indexOf('3') != -1) {
  295. this.setData({
  296. show3: true
  297. });
  298. }
  299. if (needparam.indexOf('4') != -1) {
  300. this.setData({
  301. show4: true
  302. });
  303. }
  304. if (needparam.indexOf('5') != -1) {
  305. this.setData({
  306. show5: true
  307. });
  308. }
  309. if (needparam.indexOf('6') != -1) {
  310. this.setData({
  311. show6: true
  312. });
  313. }
  314. }
  315. },
  316. getphonenumber(event) {
  317. const detail = event.detail;
  318. const _ts = this;
  319. if (!detail || !detail.encryptedData || !detail.iv) return false;
  320. req.postRequest('/api/weixin/mobile', {
  321. encryptedData: detail.encryptedData,
  322. iv: detail.iv,
  323. sessionKey: this.sessionKey
  324. }, res => {
  325. console.info(res);
  326. this.setData({
  327. phone: res.mobile,
  328. disablephone: true
  329. }); // _ts.getInfo();
  330. });
  331. },
  332. formSubmit(event) {
  333. console.log('>>>>>>>>>>>>>>>>>>>>>>>>>');
  334. let data = event.detail.value;
  335. let sfz = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  336. let myreg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
  337. // console.log(data.distriUserPhone, this.distriUserPhone);
  338. // console.log(data);
  339. if (this.show) {
  340. if (!data.title) return req.msg('请填写申请人姓名');
  341. }
  342. if (this.show2) {
  343. if (!data.phone) return req.msg('请填写手机号'); //判断电话是否正确
  344. if (!myreg.test(data.phone)) {
  345. return req.msg('请填写正确的手机号码!');
  346. }
  347. }
  348. if (this.show3) {
  349. //改动
  350. if (this.data.cardNo != null) {
  351. data.idCard = this.data.cardNo;
  352. }
  353. if (!data.idCard) return req.msg('请填写身份证信息'); //判断身份证是否正确
  354. if (!sfz.test(data.idCard)) {
  355. return req.msg('请填写正确的身份证信息!');
  356. }
  357. }
  358. if (this.show4) {
  359. data.type = '1';
  360. if (this.pid == "0"||this.pid == "" || this.pid == null) {
  361. data.type = '0';
  362. if (!data.distriUserPhone) return req.msg('请填写推荐人手机号');
  363. if (!myreg.test(data.distriUserPhone)) {
  364. return req.msg('请填写正确的推荐人手机号码!');
  365. }
  366. }
  367. }
  368. if (this.show5) {
  369. if (this.data.birthday == null) {
  370. data.birthday = this.date;
  371. } else {
  372. data.birthday = this.data.birthday;
  373. }
  374. if (data.birthday == '') return req.msg('请选择生日日期');
  375. // console.log(this.data.birthday);
  376. }
  377. if (this.show6) {
  378. if (this.data.gender == null) {
  379. data.sex = this.sex;
  380. } else {
  381. data.sex = this.data.gender;
  382. }
  383. if (data.sex == '') return req.msg('请选择性别');
  384. }
  385. this.submitApplymap(data);
  386. },
  387. //提交分销申请
  388. submitApplymap(data) {
  389. // console.log('提交申请数据' + JSON.stringify(data));
  390. req.postRequest('/api/distribution/applymap', data, dto => {
  391. // console.log(dto);
  392. if (dto.code == 0) {
  393. // this.setData({
  394. // showform2:true,
  395. // showform:true
  396. // })
  397. this.getmyinfo();
  398. } else {
  399. this.setData({
  400. msg: data.msg,
  401. isShowPage: true,
  402. showform: false
  403. });
  404. }
  405. });
  406. },
  407. radioChange(e) {
  408. // console.log('radio发生change事件,携带value值为:', e.detail.value);
  409. let items = this.item;
  410. for (let i = 0, len = items.length; i < len; ++i) {
  411. items[i].checked = items[i].value === e.detail.value;
  412. }
  413. this.setData({
  414. sex: e.detail.value
  415. });
  416. // console.log(this.sex);
  417. },
  418. bindDateChange: function(e) {
  419. // console.log('picker发送选择改变,携带值为', e.detail.value);
  420. this.setData({
  421. date: e.detail.value
  422. });
  423. }
  424. }
  425. };
  426. </script>
  427. <style>
  428. @import "./apply.css";
  429. </style>