apply.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view v-if="isShowView">
  3. <image src="../static/promote/images/info_ban.png" mode="widthFix" class="info_ban"></image>
  4. <view class="ifelse" v-if="distributionType != 0">
  5. <view class="tits">成为合伙人条件</view>
  6. <view class="iftit ddflex">
  7. <image src="../static/promote/images/info_ico.png"></image>
  8. <view class="fflex">
  9. {{ info1 }}
  10. <text>{{ distributionValue }}</text>
  11. {{ info2 }}
  12. </view>
  13. </view>
  14. <view class="leiji">
  15. {{ info3 }}
  16. <text>{{ userValue }}</text>
  17. {{ info2 }},还差
  18. <text>{{ chaUserValue }}</text>
  19. {{ info2 }}
  20. </view>
  21. <view class="percent">
  22. <view :style="'width:' + percent + '%;'"></view>
  23. </view>
  24. </view>
  25. <view class="box">
  26. <view class="tit">请填写申请信息</view>
  27. <view class="form">
  28. <view class="li ddflex" v-if="showName">
  29. <view class="label">姓名</view>
  30. <input v-model="title" placeholder="请填写你的真实姓名" placeholder-class="placeholder" class="ipt fflex" />
  31. </view>
  32. <view class="li ddflex" v-if="showPhone">
  33. <view class="label">手机号</view>
  34. <view class="item active fflex" v-if="phone">{{ phone }}</view>
  35. <block v-else>
  36. <!-- #ifdef MP-WEIXIN -->
  37. <button hover-class="none" open-type="getPhoneNumber" @getphonenumber="getphonenumber"
  38. class="phone-btn fflex">请填写手机号</button>
  39. <!-- #endif -->
  40. <!-- #ifndef MP-WEIXIN -->
  41. <input v-model="phone" placeholder="请填写手机号" type="number" maxlength="11"
  42. placeholder-class="placeholder" class="ipt fflex" />
  43. <!-- #endif -->
  44. </block>
  45. </view>
  46. <view class="li ddflex" v-if="showCard">
  47. <view class="label">身份证号</view>
  48. <input v-model="cardNo" maxlength="18" placeholder="请填写你的身份证号" placeholder-class="placeholder"
  49. class="ipt fflex" />
  50. </view>
  51. <view class="li ddflex" v-if="showSex">
  52. <view class="label">性别</view>
  53. <view class="sex ddflex fflex">
  54. <view class="lis ddflex" @click="selGender(1)">
  55. <image :src="'../static/promote/images/' + (gender == 1 ? 'radio_h.png' : 'radio.png')"
  56. class="radio"></image>
  57. <image src="../static/promote/images/man.png" class="sex-ico"></image>
  58. </view>
  59. <view class="lis ddflex" @click="selGender(2)">
  60. <image :src="'../static/promote/images/' + (gender == 2 ? 'radio_h.png' : 'radio.png')"
  61. class="radio"></image>
  62. <image src="../static/promote/images/women.png" class="sex-ico"></image>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="li ddflex" v-if="showRecommend">
  67. <view class="label">邀请人</view>
  68. <!-- label-spe -->
  69. <block v-if="this.pid != null && this.pid != 0"><input v-model="distriUserPhone" disabled="true"
  70. placeholder-class="placeholder" class="ipt fflex" /></block>
  71. <input v-model="distriUserPhone" placeholder="请填写邀请人手机号" placeholder-class="placeholder"
  72. class="ipt fflex" v-else />
  73. </view>
  74. <view class="li ddflex" v-if="showBirthday">
  75. <view class="label">出生年月</view>
  76. <view :class="'item fflex ' + (birthday ? 'active' : '')">
  77. <picker mode="date" :value="birthday" @change="bindDateChange">
  78. <view class="picker">{{ birthday ? birthday : '请选择出生年月' }}</view>
  79. </picker>
  80. </view>
  81. <image src="/static/pages/images/more.png" class="rico"></image>
  82. </view>
  83. <view class="li ddflex" v-if="showPosition">
  84. <view class="label">地址</view>
  85. <input v-model="position" placeholder="请填写地址" placeholder-class="placeholder" class="ipt fflex" />
  86. </view>
  87. </view>
  88. </view>
  89. <view class="bot">
  90. <view class="agree ddflex">
  91. <view class="dflex" @click="agree()">
  92. <image :src="'../static/promote/images/' + (isAgree ? 'gou_h1.png' : 'gou.png')"></image>
  93. 我已阅读并了解
  94. </view>
  95. <view class="ddflex fflex">
  96. <navigator url="/mine/page/page?title=申请成为合伙人协议&isGroup=true" hover-class="none">《申请成为合伙人协议》
  97. </navigator>
  98. </view>
  99. </view>
  100. <view class="btn" @click="submit()">申请成为合伙人</view>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. // promote/apply/apply.js
  106. // promote/team/team.js
  107. const app = getApp();
  108. const req = require('../../utils/request.js');
  109. export default {
  110. data() {
  111. return {
  112. isShowView: false,
  113. picUrlss: req.public.picUrls,
  114. isDistriUser: '',
  115. distributionType: '',
  116. distributionValue: '',
  117. title: '',
  118. phone: '',
  119. cardNo: '',
  120. gender: 1,
  121. pid: '',
  122. distriUserPhone: '',
  123. birthday: '',
  124. position: '', //地区
  125. isAgree: false,
  126. info1: '',
  127. info2: '',
  128. userValue: 0,
  129. chaUserValue: 0,
  130. percent: 0,
  131. info3: '',
  132. showName: false,
  133. showPhone: false,
  134. showCard: false,
  135. showRecommend: false,
  136. showBirthday: false,
  137. showSex: false,
  138. showPosition: false,
  139. distributionIsExamine: ''
  140. };
  141. },
  142. onLoad: function(options) {
  143. let _ts = this;
  144. app.globalData.getCheckSessoin(json => {
  145. _ts.sessionKey = json.session_key;
  146. });
  147. },
  148. onShow() {
  149. this.getmyinfo();
  150. },
  151. methods: {
  152. getmyinfo: function() {
  153. let that = this;
  154. req.getRequest('/api/user/info', {}, data => {
  155. // console.log(data);
  156. this.isDistriUser = data.isDistriUser;
  157. this.pid = data.pid;
  158. this.title = data.nickName;
  159. if (data && data.mobile) {
  160. this.phone = data.mobile;
  161. }
  162. if (data && data.cardNo) {
  163. this.cardNo = data.cardNo;
  164. }
  165. if (data && data.gender) {
  166. this.gender = data.gender == 2 ? 2 : 1;
  167. }
  168. if (data && data.pid) {
  169. this.distriUserPhone = data.pid;
  170. this.pid = data.pid;
  171. }
  172. if (data && data.birthday) {
  173. this.birthday = data.birthday;
  174. }
  175. // this.data = data;
  176. that.getdistri();
  177. });
  178. },
  179. getdistri() {
  180. req.postRequest('/api/distribution/config', {}, data => {
  181. // console.log(data.distributionApply + "==========================================");
  182. // if (this.isDistriUser == 2 || data.distributionApply == 0) {
  183. // uni.redirectTo({
  184. // url: '/promote/team/team'
  185. // });
  186. // }
  187. this.distributionIsExamine = data.distributionIsExamine;
  188. this.distributionType = data.distributionType;
  189. this.getDistribution(data);
  190. this.isShowView = true;
  191. }, true);
  192. },
  193. getDistribution(data) {
  194. let that = this;
  195. // wx.hideLoading();
  196. // console.log(data);
  197. /**
  198. * 判断请求回来的data是不是null的 如果是就是管理员还没配置
  199. */
  200. if (data == null) {
  201. this.setData({
  202. isno: true
  203. });
  204. } //判断分销商条件
  205. that.distributionValue = '≥' + data.distributionValue;
  206. that.userValue = data.userValue == null ? 0 : data.userValue;
  207. let cha = parseFloat(data.distributionValue) - parseFloat(that.userValue);
  208. that.chaUserValue = cha >= 0 ? cha : 0;
  209. let percent = parseInt((that.userValue / data.distributionValue) * 100);
  210. that.percent = percent <= 100 ? percent : 100;
  211. if (data.distributionType == '1') {
  212. that.info1 = '需要订单总金额';
  213. that.info2 = '元';
  214. that.info3 = '累计完成金额';
  215. } else if (data.distributionType == '2') {
  216. that.info1 = '需要订单总数量';
  217. that.info2 = '单';
  218. that.info3 = '累计完成';
  219. } else if (data.distributionType == '4') {
  220. that.info1 = '推荐用户注册数';
  221. that.info2 = '人';
  222. that.info3 = '累计邀请注册';
  223. }
  224. if (true) {
  225. let needparam = data.distributionNeedParam;
  226. // console.log(needparam);
  227. if (needparam.indexOf('1') != -1) {
  228. this.showName = true;
  229. }
  230. if (needparam.indexOf('2') != -1) {
  231. this.showPhone = true;
  232. }
  233. if (needparam.indexOf('3') != -1) {
  234. this.showCard = true;
  235. }
  236. if (needparam.indexOf('4') != -1) {
  237. this.showRecommend = true;
  238. }
  239. if (needparam.indexOf('5') != -1) {
  240. this.showBirthday = true;
  241. }
  242. if (needparam.indexOf('6') != -1) {
  243. this.showSex = true;
  244. }
  245. if (needparam.indexOf('7') != -1) {
  246. this.showPosition = true;
  247. }
  248. }
  249. },
  250. getphonenumber(event) {
  251. const detail = event.detail;
  252. const _ts = this;
  253. if (!detail || !detail.encryptedData || !detail.iv) return false;
  254. req.postRequest(
  255. '/api/weixin/mobile', {
  256. encryptedData: detail.encryptedData,
  257. iv: detail.iv,
  258. sessionKey: _ts.sessionKey
  259. },
  260. res => {
  261. let userInfo = req.getStorage('userInfo');
  262. userInfo.mobile = res.mobile;
  263. req.setStorage('userInfo', userInfo);
  264. _ts.phone = res.mobile;
  265. }
  266. );
  267. },
  268. selGender(idx) {
  269. this.gender = idx;
  270. },
  271. bindDateChange(e) {
  272. this.birthday = e.detail.value;
  273. },
  274. agree() {
  275. this.isAgree = !this.isAgree;
  276. },
  277. submit() {
  278. let data = {};
  279. 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]$/;
  280. let myreg = /^1[3|4|5|6|7|8|9][0-9]{9}$/;
  281. if (this.showName) {
  282. if (!this.title) return req.msg('请填写申请人姓名');
  283. data.title = this.title;
  284. }
  285. if (this.showPhone) {
  286. if (!this.phone) return req.msg('请填写手机号'); //判断电话是否正确
  287. if (!myreg.test(this.phone)) {
  288. return req.msg('请填写正确的手机号码!');
  289. }
  290. data.phone = this.phone;
  291. }
  292. if (this.showCard) {
  293. if (!this.cardNo) return req.msg('请填写身份证信息'); //判断身份证是否正确
  294. if (!sfz.test(this.cardNo)) {
  295. return req.msg('请填写正确的身份证信息!');
  296. }
  297. data.cardNo = this.cardNo;
  298. }
  299. if (this.showRecommend) {
  300. // data.type = '1';
  301. if (this.pid == '0' || this.pid == '' || this.pid == null) {
  302. // data.type = '0';
  303. if (!this.distriUserPhone) return req.msg('请填写推荐人手机号');
  304. if (!myreg.test(this.distriUserPhone)) {
  305. return req.msg('请填写正确的推荐人手机号码!');
  306. }
  307. data.distriUserPhone = this.distriUserPhone;
  308. } else {
  309. data.distriUserPhone = this.pid;
  310. }
  311. }
  312. if (this.showBirthday) {
  313. if (this.birthday == '') return req.msg('请选择生日日期');
  314. data.birthday = this.birthday;
  315. }
  316. if (this.showPosition) {
  317. if (this.position == '') return req.msg('请填写地区');
  318. data.address = this.position;
  319. }
  320. if (this.showSex) {
  321. data.sex = this.gender;
  322. }
  323. if (!this.isAgree) return req.msg('请阅读并同意合伙人用户协议');
  324. this.submitApplymap(data);
  325. },
  326. //提交分销申请
  327. submitApplymap(data) {
  328. // console.log('提交申请数据' + JSON.stringify(data));
  329. req.postRequest('/api/distribution/apply?v=1.6', data, dto => {
  330. // console.log(dto);
  331. if (this.distributionIsExamine == 0) {
  332. uni.navigateBack();
  333. } else {
  334. uni.redirectTo({
  335. url: '/promote/status/status'
  336. });
  337. }
  338. });
  339. }
  340. }
  341. };
  342. </script>
  343. <style>
  344. @import './apply.css';
  345. </style>