apply.vue 9.8 KB

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