index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. this.isComerGift = true;
  197. res.data['register_give_integral'] = res.data.level_give_integral;
  198. res.data['register_give_money'] = res.data.level_give_money;
  199. res.data['register_give_coupon'] = res.data.level_give_coupon;
  200. res.data['coupon_count'] = res.data.level_give_coupon.length;
  201. this.comerGift = res.data;
  202. }).catch(err=>{
  203. return this.$util.Tips({
  204. title: err
  205. });
  206. })
  207. },
  208. // 省市区地址处理逻辑;
  209. addressList(){
  210. this.getCityList();
  211. },
  212. // 获取地址数据
  213. getCityList() {
  214. let that = this;
  215. getCity().then(res => {
  216. this.district = res.data
  217. that.initialize();
  218. })
  219. },
  220. // 处理地址数据
  221. initialize: function() {
  222. let that = this,
  223. province = [],
  224. city = [],
  225. area = [];
  226. if (that.district.length) {
  227. let cityChildren = that.district[0].c || [];
  228. let areaChildren = cityChildren.length ? (cityChildren[0].c || []) : [];
  229. that.district.forEach(function(item) {
  230. province.push(item.n);
  231. });
  232. cityChildren.forEach(function(item) {
  233. city.push(item.n);
  234. });
  235. areaChildren.forEach(function(item) {
  236. area.push(item.n);
  237. });
  238. this.multiArray = [province, city, area]
  239. }
  240. },
  241. bindRegionChange(e,index) {
  242. let multiIndex = this.multiIndex,
  243. province = this.district[multiIndex[0]] || {
  244. c: []
  245. },
  246. city = province.c[multiIndex[1]] || {
  247. v: 0
  248. },
  249. multiArray = this.multiArray,
  250. value = e.detail.value;
  251. this.region = [multiArray[0][value[0]], multiArray[1][value[1]], multiArray[2][value[2]]]
  252. this.list[index].value = city.v;
  253. this.valueRegion = [0, 0, 0]
  254. this.initialize();
  255. },
  256. bindMultiPickerColumnChange(e) {
  257. let that = this,
  258. column = e.detail.column,
  259. value = e.detail.value,
  260. currentCity = this.district[value] || {
  261. c: []
  262. },
  263. multiArray = that.multiArray,
  264. multiIndex = that.multiIndex;
  265. multiIndex[column] = value;
  266. switch (column) {
  267. case 0:
  268. let areaList = currentCity.c[0] || {
  269. c: []
  270. };
  271. multiArray[1] = currentCity.c.map((item) => {
  272. return item.n;
  273. });
  274. multiArray[2] = areaList.c.map((item) => {
  275. return item.n;
  276. });
  277. break;
  278. case 1:
  279. let cityList = that.district[multiIndex[0]].c[multiIndex[1]].c || [];
  280. multiArray[2] = cityList.map((item) => {
  281. return item.n;
  282. });
  283. break;
  284. case 2:
  285. break;
  286. }
  287. // #ifdef MP || APP-PLUS
  288. this.$set(this.multiArray, 0, multiArray[0]);
  289. this.$set(this.multiArray, 1, multiArray[1]);
  290. this.$set(this.multiArray, 2, multiArray[2]);
  291. // #endif
  292. // #ifdef H5
  293. this.multiArray = multiArray;
  294. // #endif
  295. this.multiIndex = multiIndex
  296. },
  297. radioChange(e, index){
  298. this.list[index].value = e.detail.value
  299. },
  300. bindDateChange: function(e, index) {
  301. this.list[index].value = e.target.value
  302. },
  303. getInfo(){
  304. levelInfo().then(res=>{
  305. res.data.forEach(item=>{
  306. if(item.format == 'radio'){
  307. item.value = '0'
  308. }else{
  309. item.value = ''
  310. }
  311. })
  312. this.list = res.data;
  313. }).catch(err=>{
  314. this.$util.Tips({
  315. title: err
  316. })
  317. })
  318. }
  319. },
  320. onReachBottom() {
  321. }
  322. }
  323. </script>
  324. <style lang="scss">
  325. .gradeActive{
  326. padding-bottom: 20rpx;
  327. .headerBg{
  328. width: 100%;
  329. height: 264rpx;
  330. background: linear-gradient(58deg, #FDC683 0%, #FFDAB6 100%);
  331. border-radius: 0 0 100rpx 100rpx;
  332. }
  333. .header{
  334. background-repeat:no-repeat;
  335. background-size: 100% 100%;
  336. width: 690rpx;
  337. height: 288rpx;
  338. margin: -236rpx auto 0 auto;
  339. font-weight: 400;
  340. color: #EDCAAC;
  341. font-size: 24rpx;
  342. padding: 78rpx 48rpx;
  343. .title{
  344. font-size: 48rpx;
  345. font-weight: 600;
  346. background: linear-gradient(180deg, #FFEFE1 0%, #FFD0A8 100%);
  347. -webkit-background-clip: text;
  348. -webkit-text-fill-color: transparent;
  349. margin-bottom: 25rpx;
  350. }
  351. }
  352. .bnt{
  353. width: 690rpx;
  354. height: 88rpx;
  355. background: linear-gradient(90deg, #FFAE49 0%, #FCC887 100%);
  356. border-radius: 44rpx;
  357. font-weight: 500;
  358. color: #FFFFFF;
  359. font-size: 30rpx;
  360. margin: 24rpx auto 0 auto;
  361. text-align: center;
  362. line-height: 88rpx;
  363. }
  364. .conter{
  365. background-color: #fff;
  366. border-radius: 14rpx;
  367. margin: 26rpx auto 0 auto;
  368. width: 690rpx;
  369. padding: 44rpx 48rpx 64rpx 48rpx;
  370. .list{
  371. margin-top: 78rpx;
  372. padding-bottom: 28rpx;
  373. position: relative;
  374. .vipBg{
  375. width: 262rpx;
  376. height: 174rpx;
  377. display: block;
  378. position: absolute;
  379. right: -48rpx;
  380. bottom: -64rpx;
  381. }
  382. .itemNo{
  383. font-weight: 400;
  384. color: #282828;
  385. font-size: 26rpx;
  386. position: relative;
  387. z-index: 1;
  388. .pictrue{
  389. width: 90rpx;
  390. height: 90rpx;
  391. margin-bottom: 12rpx;
  392. image{
  393. width: 100%;
  394. height: 100%;
  395. border-radius: 50%;
  396. }
  397. }
  398. }
  399. }
  400. .item{
  401. font-size: 24rpx;
  402. color: #666;
  403. height: 156rpx;
  404. border-bottom: 1px solid #F5F5F5;
  405. padding-top: 40rpx;
  406. /deep/uni-radio{
  407. vertical-align: bottom;
  408. margin-right: 10rpx;
  409. }
  410. /deep/uni-radio .uni-radio-input{
  411. width: 28rpx;
  412. height: 28rpx;
  413. border: 1px solid #E6993A;
  414. }
  415. /deep/uni-radio .uni-radio-input.uni-radio-input-checked{
  416. border: 1px solid #E6993A !important;
  417. background-color: #E6993A !important;
  418. }
  419. /deep/.wx-radio-input {
  420. width: 28rpx;
  421. height: 28rpx;
  422. border: 1px solid #E6993A;
  423. }
  424. /deep/.wx-radio-input.wx-radio-input-checked {
  425. border: 1px solid #E6993A !important;
  426. background-color: #E6993A !important;
  427. }
  428. /deep/uni-radio .uni-radio-input.uni-radio-input-checked:before{
  429. font-size: 24rpx;
  430. }
  431. .label{
  432. margin-right: 80rpx;
  433. }
  434. .name{
  435. position: relative;
  436. margin-left: 17rpx;
  437. .asterisk{
  438. color: #E93323;
  439. position: absolute;
  440. color:red;
  441. left:-15rpx
  442. }
  443. }
  444. .placeholder{
  445. font-size: 28rpx;
  446. font-weight: 400;
  447. color: #CCCCCC;
  448. }
  449. .input{
  450. margin-top: 24rpx;
  451. padding: 0 30rpx;
  452. .iconfont{
  453. font-size: 24rpx;
  454. color: #999;
  455. }
  456. input{
  457. font-size: 28rpx;
  458. }
  459. }
  460. }
  461. .headerT{
  462. font-size: 30rpx;
  463. color: #CC803B;
  464. .name{
  465. margin: 0 40rpx;
  466. }
  467. .pictrue{
  468. width: 124rpx;
  469. height: 22rpx;
  470. image{
  471. width: 100%;
  472. height: 100%;
  473. display: block;
  474. }
  475. &.on{
  476. transform: rotateX(180deg);
  477. }
  478. }
  479. }
  480. }
  481. }
  482. </style>