index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view class="gradeActive">
  3. <view class="headerBg"></view>
  4. <view class="header" :style="{backgroundImage:'url('+imgHost+'/statics/images/grade-active.png'+')'}">
  5. <view class="title">激活会员卡</view>
  6. <view>新用户免费激活会员卡</view>
  7. </view>
  8. <view class="conter">
  9. <view class="headerT acea-row row-center-wrapper">
  10. <view class="pictrue">
  11. <image src="../static/left.png"></image>
  12. </view>
  13. <view class="name">{{list.length?'填写以下信息':'我的成长特权'}}</view>
  14. <view class="pictrue on">
  15. <image src="../static/left.png"></image>
  16. </view>
  17. </view>
  18. <view class="list acea-row row-between-wrapper" v-if="!list.length">
  19. <view class="itemNo">
  20. <view class="pictrue">
  21. <image :src="imgHost+'/statics/images/userVip1.png'"></image>
  22. </view>
  23. <view>购物折扣</view>
  24. </view>
  25. <view class="itemNo">
  26. <view class="pictrue">
  27. <image :src="imgHost+'/statics/images/userVip2.png'"></image>
  28. </view>
  29. <view>专属徽章</view>
  30. </view>
  31. <view class="itemNo">
  32. <view class="pictrue">
  33. <image :src="imgHost+'/statics/images/userVip3.png'"></image>
  34. </view>
  35. <view>经验累积</view>
  36. </view>
  37. <view class="itemNo">
  38. <view class="pictrue">
  39. <image :src="imgHost+'/statics/images/userVip4.png'"></image>
  40. </view>
  41. <view>尊享客服</view>
  42. </view>
  43. <image class="vipBg" src="../static/vipBg.png"></image>
  44. </view>
  45. <view class="item" v-for="(item,index) in list" :key="index">
  46. <view class="name"><text class="asterisk" v-if="item.required==1">*</text><text>{{item.info}}</text></view>
  47. <!-- text -->
  48. <view class="input" v-if="item.format == 'text'">
  49. <input type="text" :placeholder="item.tip" placeholder-class="placeholder" v-model="item.value" />
  50. </view>
  51. <!-- number -->
  52. <view class="input" v-if="item.format=='num'">
  53. <input type="number" :placeholder="item.tip" placeholder-class="placeholder" v-model="item.value" />
  54. </view>
  55. <!-- email -->
  56. <view class="input" v-if="item.format=='mail'">
  57. <input type="text" :placeholder="item.tip" placeholder-class="placeholder" v-model="item.value" />
  58. </view>
  59. <!-- date -->
  60. <view class="input" v-if="item.format=='date'">
  61. <picker mode="date" :value="item.value" @change="bindDateChange($event,index)">
  62. <view class="acea-row row-between-wrapper">
  63. <view v-if="item.value == ''">{{item.tip}}</view>
  64. <view v-else>{{item.value}}</view>
  65. <text class='iconfont icon-jiantou'></text>
  66. </view>
  67. </picker>
  68. </view>
  69. <!-- id -->
  70. <view class="input" v-if="item.format=='id'">
  71. <input type="idcard" :placeholder="item.tip" placeholder-class="placeholder" v-model="item.value" />
  72. </view>
  73. <!-- phone -->
  74. <view class="input" v-if="item.format=='phone'">
  75. <input type="tel" :placeholder="item.tip" placeholder-class="placeholder" v-model="item.value" />
  76. </view>
  77. <!-- radio -->
  78. <view class="input" v-if="item.format=='radio'">
  79. <radio-group @change="radioChange($event,index)">
  80. <label class="label">
  81. <radio value="0" :checked="item.value == 0" />{{item.singlearr[0]}}
  82. </label>
  83. <label>
  84. <radio value="1" :checked="item.value == 1" />{{item.singlearr[1]}}
  85. </label>
  86. </radio-group>
  87. </view>
  88. <!-- address -->
  89. <view class="input" @click="addressList" v-if="item.format=='address'">
  90. <picker mode="multiSelector" @change="bindRegionChange($event,index)"
  91. @columnchange="bindMultiPickerColumnChange" :value="valueRegion"
  92. :range="multiArray">
  93. <view class='acea-row row-between-wrapper'>
  94. <view class="picker">{{region[0]}},{{region[1]}},{{region[2]}}</view>
  95. <text class='iconfont icon-jiantou'></text>
  96. </view>
  97. </picker>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="bnt" @click="activate">确认激活</view>
  102. <ewcomerPop v-if="isComerGift" :fromActive="1" :comerGift="comerGift" @comerPop="comerPop"></ewcomerPop>
  103. </view>
  104. </template>
  105. <script>
  106. import {
  107. levelInfo,
  108. levelActivate
  109. } from '@/api/user.js';
  110. import {
  111. getCity
  112. } from '@/api/api.js';
  113. import {
  114. HTTP_REQUEST_URL
  115. } from '@/config/app';
  116. import ewcomerPop from '@/components/ewcomerPop/index.vue'
  117. export default {
  118. components: {
  119. ewcomerPop
  120. },
  121. data() {
  122. return {
  123. imgHost: HTTP_REQUEST_URL,
  124. list:[],
  125. district: [],
  126. multiArray: [],
  127. multiIndex: [0, 0, 0],
  128. valueRegion: [0, 0, 0],
  129. region: ['省', '市', '区'],
  130. comerGift:{},
  131. isComerGift:false
  132. };
  133. },
  134. onLoad() {
  135. this.getInfo();
  136. },
  137. onReady() {},
  138. onShow() {},
  139. methods: {
  140. comerPop(){
  141. this.isComerGift = false;
  142. uni.navigateTo({
  143. url: '/pages/annex/vip_grade/index'
  144. })
  145. },
  146. activate(){
  147. let that = this;
  148. for (var i = 0; i < that.list.length; i++) {
  149. let data = that.list[i]
  150. if (data.required || data.value) {
  151. if (data.format === 'date' || data.format === 'address') {
  152. if (!data.value) {
  153. return that.$util.Tips({
  154. title: `${data.tip}`
  155. });
  156. }
  157. }
  158. if(data.format === 'text'){
  159. if (!data.value.trim()) {
  160. return that.$util.Tips({
  161. title: `${data.tip}`
  162. });
  163. }
  164. }
  165. if (data.format === 'num') {
  166. if (data.value <= 0) {
  167. return that.$util.Tips({
  168. title: `${data.tip}`
  169. });
  170. }
  171. }
  172. if (data.format === 'mail') {
  173. if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(data.value)) {
  174. return that.$util.Tips({
  175. title: `${data.tip}`
  176. });
  177. }
  178. }
  179. if (data.format === 'phone') {
  180. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(data.value)) {
  181. return that.$util.Tips({
  182. title: `${data.tip}`
  183. });
  184. }
  185. }
  186. if (data.format === 'id') {
  187. if (!/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/i.test(data.value)) {
  188. return that.$util.Tips({
  189. title: `${data.tip}`
  190. });
  191. }
  192. }
  193. }
  194. }
  195. levelActivate(this.list).then(res=>{
  196. res.data['register_give_integral'] = res.data.level_give_integral;
  197. res.data['register_give_money'] = res.data.level_give_money;
  198. res.data['register_give_coupon'] = res.data.level_give_coupon;
  199. res.data['coupon_count'] = res.data.level_give_coupon.length;
  200. this.comerGift = res.data;
  201. if(res.data.level_give_integral>0 || res.data.level_give_money>0 || res.data.level_give_coupon.length>0){
  202. this.isComerGift = true;
  203. }else{
  204. uni.navigateTo({
  205. url: '/pages/annex/vip_grade/index'
  206. })
  207. }
  208. }).catch(err=>{
  209. return this.$util.Tips({
  210. title: err
  211. });
  212. })
  213. },
  214. // 省市区地址处理逻辑;
  215. addressList(){
  216. this.getCityList();
  217. },
  218. // 获取地址数据
  219. getCityList() {
  220. let that = this;
  221. getCity().then(res => {
  222. this.district = res.data
  223. that.initialize();
  224. })
  225. },
  226. // 处理地址数据
  227. initialize: function() {
  228. let that = this,
  229. province = [],
  230. city = [],
  231. area = [];
  232. if (that.district.length) {
  233. let cityChildren = that.district[0].c || [];
  234. let areaChildren = cityChildren.length ? (cityChildren[0].c || []) : [];
  235. that.district.forEach(function(item) {
  236. province.push(item.n);
  237. });
  238. cityChildren.forEach(function(item) {
  239. city.push(item.n);
  240. });
  241. areaChildren.forEach(function(item) {
  242. area.push(item.n);
  243. });
  244. this.multiArray = [province, city, area]
  245. }
  246. },
  247. bindRegionChange(e,index) {
  248. let multiIndex = this.multiIndex,
  249. province = this.district[multiIndex[0]] || {
  250. c: []
  251. },
  252. city = province.c[multiIndex[1]] || {
  253. v: 0
  254. },
  255. multiArray = this.multiArray,
  256. value = e.detail.value;
  257. this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]]
  258. this.list[index].value = city.v;
  259. this.valueRegion = [0, 0, 0]
  260. this.initialize();
  261. },
  262. bindMultiPickerColumnChange(e) {
  263. let that = this,
  264. column = e.detail.column,
  265. value = e.detail.value,
  266. currentCity = this.district[value] || {
  267. c: []
  268. },
  269. multiArray = that.multiArray,
  270. multiIndex = that.multiIndex;
  271. multiIndex[column] = value;
  272. switch (column) {
  273. case 0:
  274. let areaList = currentCity.c[0] || {
  275. c: []
  276. };
  277. multiArray[1] = currentCity.c.map((item) => {
  278. return item.n;
  279. });
  280. multiArray[2] = areaList.c.map((item) => {
  281. return item.n;
  282. });
  283. break;
  284. case 1:
  285. let cityList = that.district[multiIndex[0]].c[multiIndex[1]].c || [];
  286. multiArray[2] = cityList.map((item) => {
  287. return item.n;
  288. });
  289. break;
  290. case 2:
  291. break;
  292. }
  293. // #ifdef MP || APP-PLUS
  294. this.$set(this.multiArray, 0, multiArray[0]);
  295. this.$set(this.multiArray, 1, multiArray[1]);
  296. this.$set(this.multiArray, 2, multiArray[2]);
  297. // #endif
  298. // #ifdef H5
  299. this.multiArray = multiArray;
  300. // #endif
  301. this.multiIndex = multiIndex
  302. },
  303. radioChange(e, index){
  304. this.list[index].value = e.detail.value
  305. },
  306. bindDateChange: function(e, index) {
  307. this.list[index].value = e.target.value
  308. },
  309. getInfo(){
  310. levelInfo().then(res=>{
  311. res.data.forEach(item=>{
  312. if(item.format == 'radio'){
  313. item.value = '0'
  314. }else{
  315. item.value = ''
  316. }
  317. })
  318. this.list = res.data;
  319. }).catch(err=>{
  320. this.$util.Tips({
  321. title: err
  322. })
  323. })
  324. }
  325. },
  326. onReachBottom() {
  327. }
  328. }
  329. </script>
  330. <style lang="scss">
  331. .gradeActive{
  332. padding-bottom: 20rpx;
  333. .headerBg{
  334. width: 100%;
  335. height: 264rpx;
  336. background: linear-gradient(58deg, #FDC683 0%, #FFDAB6 100%);
  337. border-radius: 0 0 100rpx 100rpx;
  338. }
  339. .header{
  340. background-repeat:no-repeat;
  341. background-size: 100% 100%;
  342. width: 690rpx;
  343. height: 288rpx;
  344. margin: -236rpx auto 0 auto;
  345. font-weight: 400;
  346. color: #EDCAAC;
  347. font-size: 24rpx;
  348. padding: 78rpx 48rpx;
  349. .title{
  350. font-size: 48rpx;
  351. font-weight: 600;
  352. background: linear-gradient(180deg, #FFEFE1 0%, #FFD0A8 100%);
  353. -webkit-background-clip: text;
  354. -webkit-text-fill-color: transparent;
  355. margin-bottom: 25rpx;
  356. }
  357. }
  358. .bnt{
  359. width: 690rpx;
  360. height: 88rpx;
  361. background: linear-gradient(90deg, #FFAE49 0%, #FCC887 100%);
  362. border-radius: 44rpx;
  363. font-weight: 500;
  364. color: #FFFFFF;
  365. font-size: 30rpx;
  366. margin: 24rpx auto 0 auto;
  367. text-align: center;
  368. line-height: 88rpx;
  369. }
  370. .conter{
  371. background-color: #fff;
  372. border-radius: 14rpx;
  373. margin: 26rpx auto 0 auto;
  374. width: 690rpx;
  375. padding: 44rpx 48rpx 64rpx 48rpx;
  376. .list{
  377. margin-top: 78rpx;
  378. padding-bottom: 28rpx;
  379. position: relative;
  380. .vipBg{
  381. width: 262rpx;
  382. height: 174rpx;
  383. display: block;
  384. position: absolute;
  385. right: -48rpx;
  386. bottom: -64rpx;
  387. }
  388. .itemNo{
  389. font-weight: 400;
  390. color: #282828;
  391. font-size: 26rpx;
  392. position: relative;
  393. z-index: 1;
  394. .pictrue{
  395. width: 90rpx;
  396. height: 90rpx;
  397. margin-bottom: 12rpx;
  398. image{
  399. width: 100%;
  400. height: 100%;
  401. border-radius: 50%;
  402. }
  403. }
  404. }
  405. }
  406. .item{
  407. font-size: 24rpx;
  408. color: #666;
  409. height: 156rpx;
  410. border-bottom: 1px solid #F5F5F5;
  411. padding-top: 40rpx;
  412. /deep/uni-radio{
  413. vertical-align: bottom;
  414. margin-right: 10rpx;
  415. }
  416. /deep/uni-radio .uni-radio-input{
  417. width: 28rpx;
  418. height: 28rpx;
  419. border: 1px solid #E6993A;
  420. }
  421. /deep/uni-radio .uni-radio-input.uni-radio-input-checked{
  422. border: 1px solid #E6993A !important;
  423. background-color: #E6993A !important;
  424. }
  425. /deep/.wx-radio-input {
  426. width: 28rpx;
  427. height: 28rpx;
  428. border: 1px solid #E6993A;
  429. }
  430. /deep/.wx-radio-input.wx-radio-input-checked {
  431. border: 1px solid #E6993A !important;
  432. background-color: #E6993A !important;
  433. }
  434. /deep/uni-radio .uni-radio-input.uni-radio-input-checked:before{
  435. font-size: 24rpx;
  436. }
  437. .label{
  438. margin-right: 80rpx;
  439. }
  440. .name{
  441. position: relative;
  442. margin-left: 17rpx;
  443. .asterisk{
  444. color: #E93323;
  445. position: absolute;
  446. color:red;
  447. left:-15rpx
  448. }
  449. }
  450. .placeholder{
  451. font-size: 28rpx;
  452. font-weight: 400;
  453. color: #CCCCCC;
  454. }
  455. .input{
  456. margin-top: 24rpx;
  457. padding: 0 30rpx;
  458. .iconfont{
  459. font-size: 24rpx;
  460. color: #999;
  461. }
  462. input{
  463. font-size: 28rpx;
  464. }
  465. }
  466. }
  467. .headerT{
  468. font-size: 30rpx;
  469. color: #CC803B;
  470. .name{
  471. margin: 0 40rpx;
  472. }
  473. .pictrue{
  474. width: 124rpx;
  475. height: 22rpx;
  476. image{
  477. width: 100%;
  478. height: 100%;
  479. display: block;
  480. }
  481. &.on{
  482. transform: rotateX(180deg);
  483. }
  484. }
  485. }
  486. }
  487. }
  488. </style>