index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="list">
  5. <scroll-view scroll-x="true" :scroll-into-view="scrollIntoView" class="lists">
  6. <view :class="'li'+(current == index ? ' active':'')" :id="'id'+index" v-for="(item,index) in pageList" :key="index" @click="checkVip(item,index)">
  7. <view class="li-c ddflex">
  8. <image :src="picUrlss+'lvluo/open_vip.png'" class="vip-ico" v-if="current == index"></image>
  9. <image :src="picUrlss+'lvluo/open_tag.png'" class="vip-tag"></image>
  10. <view class="tit"><view v-if="item.brief">{{item.brief}}</view>{{item.title}}</view>
  11. <view class="zhe" v-if="item.gradesEquity"><text v-for="(it,idx) in JSON.parse(item.gradesEquity)" :key="idx" v-if="it.bind == 'consume'">立享{{it.value}}折</text></view>
  12. </view>
  13. </view>
  14. </scroll-view>
  15. </view>
  16. <view class="cons" v-if="pageList[current].editorContent">
  17. <image :src="picUrlss+'lvluo/open_bg.png'" class="open-bg"></image>
  18. <view class="tis">开通即可享受</view>
  19. <view class="con-s">
  20. <rich-text :nodes="pageList[current].editorContent"></rich-text>
  21. <!-- <mp-html :content="pageList[current].editorContent" :lazy-load="true" @imgtap="choose"></mp-html> -->
  22. </view>
  23. </view>
  24. <block v-if="pageList[current].levelStrategyDTOList&&pageList[current].levelStrategyDTOList.length > 0">
  25. <view class="vip-list" v-if="checkItem.price != 0">
  26. <view class="vip-tit">开通时长</view>
  27. <view class="vip-lists">
  28. <view class="li ddflex" v-for="(item,index) in pageList[current].levelStrategyDTOList" :key="index" @click="checkVips(item,index)" v-if="item.price > 0">
  29. <view class="vip-tits fflex">{{item.strategyTitle}}</view>
  30. <view class="vip-money">
  31. <view class="money"><text>¥</text>{{item.price}}</view>
  32. <view class="del" v-if="item.originalPrice > 0">¥{{item.originalPrice}}</view>
  33. </view>
  34. <image :src="picUrlss+(vipCurrent == index ? 'lvluo/open_gou_h.png' : 'lvluo/open_gou.png')" class="gou"></image>
  35. </view>
  36. </view>
  37. </view>
  38. </block>
  39. <!-- <view class="vip-list" v-if="vipList.length > 0 && money > 0">
  40. <view class="vip-tit">开通时长</view>
  41. <view class="vip-lists">
  42. <view class="li ddflex" v-for="(item,index) in vipList" :key="index" @click="checkVips(item,index)">
  43. <view class="vip-tits fflex">{{item.day == '30' ? '连续包月VIP':'年度VIP'}}</view>
  44. <view class="vip-money">
  45. <view class="money"><text>¥</text>{{item.price}}</view>
  46. <view class="del">¥{{item.originalPrice}}</view>
  47. </view>
  48. <image :src="picUrlss+(vipCurrent == index ? 'lvluo/open_gou_h.png' : 'lvluo/open_gou.png')" class="gou"></image>
  49. </view>
  50. </view>
  51. </view> -->
  52. </view>
  53. <view style="height: 176rpx;"></view>
  54. <view class="bot ddflex">
  55. <block v-if="checkItem && checkItem.price!=0">
  56. <view class="fflex ddflex" style="align-items: flex-end;">
  57. <view class="price"><text>¥</text>{{money}}</view>
  58. <view class="hui" v-if="saleMoney > 0">优惠¥{{saleMoney}}</view>
  59. </view>
  60. <view class="mingxi ddflex" @click="showPop">明细<image src="../../static/pages/images/bico.png"></image></view>
  61. <view class="btns" @click="buy()">{{userinfoVip.level == pageList[current].id && userinfoVip.level != 0 && !userinfoVip.end ? '立即续费':'立即开通'}}</view>
  62. </block>
  63. <block v-else>
  64. <view class="btn fflex" @click="buy()" v-if="userinfoVip.level == pageList[current].id && userinfoVip.level != 0 && !userinfoVip.end">立即续费</view>
  65. <view class="btn fflex" v-else @click="buy()">{{checkItem.price > 0 ? '立即开通':'免费开通'}}</view>
  66. </block>
  67. </view>
  68. <view class="ceng" v-if="isShowPop" @click="hidePop"></view>
  69. <view class="popup" :style="'bottom:' +popBottom">
  70. <image src="../../static/pages/images/close1.png" class="pop-close" @click="hidePop"></image>
  71. <view class="pop-tit">支付明细</view>
  72. <view class="pop-tits">{{pageList[current].brief + '·' + pageList[current].title}}</view>
  73. <view class="pop-info ddflex">
  74. <view class="fflex">{{checkItem.strategyTitle}}</view>
  75. <view class="del" v-if="checkItem.originalPrice > 0">¥{{checkItem.originalPrice}}</view>
  76. <view class="pop-money">¥{{money}}</view>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. const app = getApp();
  83. const req = require("../../utils/request.js");
  84. const route = require('../../utils/route');
  85. const utils = require('../../utils/util.js');
  86. import mpHtml from "@/components/mp-html/components/mp-html/mp-html.vue"
  87. export default {
  88. components: {
  89. mpHtml
  90. },
  91. data() {
  92. return {
  93. picUrlss: req.public.picUrls,
  94. opt: {},
  95. current: 0,
  96. pageList: [],
  97. vipList: [],
  98. vipCurrent: 0,
  99. money: 0,
  100. saleMoney: 0,
  101. isShowPop: false,
  102. popBottom: '-100%',
  103. userinfoVip: '',
  104. scrollIntoView: 'id0',
  105. checkItem: '',
  106. config: ''
  107. };
  108. },
  109. onLoad: async function(options) {
  110. this.opt = options;
  111. this.config = JSON.parse(req.getStorage('configRes'));
  112. if(options.levelId){
  113. uni.setNavigationBarTitle({
  114. title: '升级健康卡'
  115. })
  116. }
  117. await this.getuserVip();
  118. await this.getNewList();
  119. // await this.getList();
  120. },
  121. methods: {
  122. getuserVip() {
  123. return new Promise((resolve,reject)=>{
  124. req.getRequest('/api/user/levelDetails', {}, data => {
  125. let expireTime = Array;
  126. if (data.expireTime) {
  127. expireTime = data.expireTime.split(' ');
  128. data.expireTime = data.expireTime.replace(/-/g, '/');
  129. }
  130. let nowTime = new Date().getTime();
  131. let endTime = new Date(data.expireTime).getTime();
  132. let times = parseInt((endTime - nowTime) / 1000);
  133. if(data.cardNo) data.cardNo = data.cardNo.replace(/(.{4}).*(.{4})/, '$1********$2');
  134. this.userinfoVip = data;
  135. this.userinfoVip.expireTime = expireTime[0];
  136. if (times <= 0) {
  137. this.userinfoVip.end = true;
  138. } else {
  139. this.userinfoVip.end = false;
  140. }
  141. resolve();
  142. });
  143. })
  144. },
  145. checkVip(item,index){
  146. if(this.current == index) return false;
  147. this.current = index;
  148. this.scrollIntoView = 'id'+this.current;
  149. this.vipCurrent = 0;
  150. this.checkItem = item.levelStrategyDTOList[0];
  151. this.calculateMoney(item.levelStrategyDTOList[0])
  152. this.$forceUpdate();
  153. // this.getVipMoneyT(item.level);
  154. },
  155. checkVips(item,index){
  156. if(this.vipCurrent == index) return false;
  157. this.vipCurrent = index;
  158. this.checkItem = item;
  159. this.calculateMoney(item)
  160. },
  161. showPop(){
  162. this.isShowPop = true;
  163. this.popBottom = 0;
  164. },
  165. hidePop(){
  166. this.isShowPop = false;
  167. this.popBottom = '-100%';
  168. },
  169. calculateMoney(obj){
  170. this.money = obj.price;
  171. if(obj.originalPrice > 0){
  172. this.saleMoney = obj.originalPrice - obj.price;
  173. }else{
  174. this.saleMoney = 0
  175. }
  176. },
  177. getNewList(){
  178. let that = this;
  179. return new Promise((resolve,reject)=>{
  180. req.getRequest('/api/levelStrategy/listV2', {}, data => {
  181. console.log('策略',data,that.opt.levelId)
  182. that.pageList = data;
  183. if(that.opt.levelId != '' && that.opt.levelId != undefined){
  184. console.log('有id')
  185. if(that.userinfoVip.levelGrade > 0 && !that.userinfoVip.end){
  186. data.map((it,idx)=>{
  187. if(it.id == that.userinfoVip.level){
  188. if(idx == data.length-1){
  189. that.current = idx;
  190. }else{
  191. that.current = idx+1;
  192. }
  193. that.scrollIntoView = 'id'+that.current;
  194. // that.getVipMoneyT(data[that.current].level);
  195. that.checkItem = data[that.current].levelStrategyDTOList[0];
  196. }
  197. })
  198. }else{
  199. data.map((it,idx)=>{
  200. if(it.id == that.opt.levelId){
  201. that.scrollIntoView = 'id'+idx;
  202. that.current = idx;
  203. // that.getVipMoneyT(data[idx].level)
  204. that.checkItem = data[idx].levelStrategyDTOList[0];
  205. }
  206. })
  207. }
  208. }else{
  209. console.log('没有id')
  210. that.scrollIntoView = 0;
  211. that.current = 0;
  212. // that.getVipMoneyT(data[0].level)
  213. that.checkItem = data[0].levelStrategyDTOList[0];
  214. console.log('that.checkItem==',that.checkItem)
  215. }
  216. that.calculateMoney(that.checkItem)
  217. resolve();
  218. });
  219. })
  220. },
  221. getList() {
  222. let that = this;
  223. return new Promise((resolve,reject)=>{
  224. req.getRequest('/api/levelStrategy/userLevelList', {}, data => {
  225. that.pageList = data;
  226. if(that.opt.levelId != ''){
  227. if(that.userinfoVip.levelGrade > 0 && !that.userinfoVip.end){
  228. data.map((it,idx)=>{
  229. if(it.id == that.userinfoVip.level){
  230. if(idx == data.length-1){
  231. that.current = idx;
  232. }else{
  233. that.current = idx+1;
  234. }
  235. that.scrollIntoView = 'id'+that.current;
  236. that.getVipMoneyT(data[that.current].level);
  237. }
  238. })
  239. }else{
  240. data.map((it,idx)=>{
  241. if(it.id == that.opt.levelId){
  242. that.scrollIntoView = 'id'+idx;
  243. that.current = idx;
  244. that.getVipMoneyT(data[idx].level)
  245. }
  246. })
  247. }
  248. }else{
  249. that.scrollIntoView = 0;
  250. that.current = 0;
  251. that.getVipMoneyT(data[0].level)
  252. }
  253. resolve();
  254. });
  255. })
  256. },
  257. getVipMoneyT(index) {
  258. let from = {
  259. level: index
  260. };
  261. return new Promise((resolve, reject) => {
  262. req.getRequest('/api/levelStrategy/list', from, data => {
  263. this.vipList = data;
  264. this.money = data[0].price;
  265. this.saleMoney = data[0].originalPrice - data[0].price;
  266. });
  267. resolve();
  268. });
  269. },
  270. //购买
  271. buy() {
  272. let that = this;
  273. route.vip(
  274. {
  275. strategyId: this.checkItem.id,
  276. scene: req.getStorage('scene')
  277. },
  278. data => {
  279. route.vipPay(data.id, data.status, this.money, res => {
  280. uni.hideLoading();
  281. app.globalData.reLaunchTo('pages/index/index');
  282. });
  283. }
  284. );
  285. },
  286. jumpUrl(url){
  287. uni.navigateTo({
  288. url: url
  289. })
  290. }
  291. }
  292. };
  293. </script>
  294. <style>
  295. @import "./index.css"
  296. </style>