index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. import h5util from "../../utils/h5util.js";
  88. export default {
  89. components: {
  90. mpHtml
  91. },
  92. data() {
  93. return {
  94. picUrlss: req.public.picUrls,
  95. opt: {},
  96. current: 0,
  97. pageList: [],
  98. vipList: [],
  99. vipCurrent: 0,
  100. money: 0,
  101. saleMoney: 0,
  102. isShowPop: false,
  103. popBottom: '-100%',
  104. userinfoVip: '',
  105. scrollIntoView: 'id0',
  106. checkItem: '',
  107. config: ''
  108. };
  109. },
  110. onLoad: async function(options) {
  111. this.opt = options;
  112. this.config = JSON.parse(req.getStorage('configRes'));
  113. if(options.levelId){
  114. uni.setNavigationBarTitle({
  115. title: '升级健康卡'
  116. })
  117. }
  118. await this.getuserVip();
  119. await this.getNewList();
  120. // await this.getList();
  121. },
  122. methods: {
  123. getuserVip() {
  124. return new Promise((resolve,reject)=>{
  125. req.getRequest('/api/user/levelDetails', {}, data => {
  126. let expireTime = Array;
  127. if (data.expireTime) {
  128. expireTime = data.expireTime.split(' ');
  129. data.expireTime = data.expireTime.replace(/-/g, '/');
  130. }
  131. let nowTime = new Date().getTime();
  132. let endTime = new Date(data.expireTime).getTime();
  133. let times = parseInt((endTime - nowTime) / 1000);
  134. if(data.cardNo) data.cardNo = data.cardNo.replace(/(.{4}).*(.{4})/, '$1********$2');
  135. this.userinfoVip = data;
  136. this.userinfoVip.expireTime = expireTime[0];
  137. if (times <= 0) {
  138. this.userinfoVip.end = true;
  139. } else {
  140. this.userinfoVip.end = false;
  141. }
  142. resolve();
  143. });
  144. })
  145. },
  146. checkVip(item,index){
  147. if(this.current == index) return false;
  148. this.current = index;
  149. this.scrollIntoView = 'id'+this.current;
  150. this.vipCurrent = 0;
  151. this.checkItem = item.levelStrategyDTOList[0];
  152. this.calculateMoney(item.levelStrategyDTOList[0])
  153. this.$forceUpdate();
  154. // this.getVipMoneyT(item.level);
  155. },
  156. checkVips(item,index){
  157. if(this.vipCurrent == index) return false;
  158. this.vipCurrent = index;
  159. this.checkItem = item;
  160. this.calculateMoney(item)
  161. },
  162. showPop(){
  163. this.isShowPop = true;
  164. this.popBottom = 0;
  165. },
  166. hidePop(){
  167. this.isShowPop = false;
  168. this.popBottom = '-100%';
  169. },
  170. calculateMoney(obj){
  171. this.money = obj.price;
  172. if(obj.originalPrice > 0){
  173. this.saleMoney = obj.originalPrice - obj.price;
  174. }else{
  175. this.saleMoney = 0
  176. }
  177. },
  178. getNewList(){
  179. let that = this;
  180. return new Promise((resolve,reject)=>{
  181. req.getRequest('/api/levelStrategy/listV2', {}, data => {
  182. console.log('策略',data,that.opt.levelId)
  183. that.pageList = data;
  184. if(that.opt.levelId != '' && that.opt.levelId != undefined){
  185. console.log('有id')
  186. if(that.userinfoVip.levelGrade > 0 && !that.userinfoVip.end){
  187. data.map((it,idx)=>{
  188. if(it.id == that.userinfoVip.level){
  189. if(idx == data.length-1){
  190. that.current = idx;
  191. }else{
  192. that.current = idx+1;
  193. }
  194. that.scrollIntoView = 'id'+that.current;
  195. // that.getVipMoneyT(data[that.current].level);
  196. that.checkItem = data[that.current].levelStrategyDTOList[0];
  197. }
  198. })
  199. }else{
  200. data.map((it,idx)=>{
  201. if(it.id == that.opt.levelId){
  202. that.scrollIntoView = 'id'+idx;
  203. that.current = idx;
  204. // that.getVipMoneyT(data[idx].level)
  205. that.checkItem = data[idx].levelStrategyDTOList[0];
  206. }
  207. })
  208. }
  209. }else{
  210. console.log('没有id')
  211. that.scrollIntoView = 0;
  212. that.current = 0;
  213. // that.getVipMoneyT(data[0].level)
  214. that.checkItem = data[0].levelStrategyDTOList[0];
  215. console.log('that.checkItem==',that.checkItem)
  216. }
  217. that.calculateMoney(that.checkItem)
  218. resolve();
  219. });
  220. })
  221. },
  222. getList() {
  223. let that = this;
  224. return new Promise((resolve,reject)=>{
  225. req.getRequest('/api/levelStrategy/userLevelList', {}, data => {
  226. that.pageList = data;
  227. if(that.opt.levelId != ''){
  228. if(that.userinfoVip.levelGrade > 0 && !that.userinfoVip.end){
  229. data.map((it,idx)=>{
  230. if(it.id == that.userinfoVip.level){
  231. if(idx == data.length-1){
  232. that.current = idx;
  233. }else{
  234. that.current = idx+1;
  235. }
  236. that.scrollIntoView = 'id'+that.current;
  237. that.getVipMoneyT(data[that.current].level);
  238. }
  239. })
  240. }else{
  241. data.map((it,idx)=>{
  242. if(it.id == that.opt.levelId){
  243. that.scrollIntoView = 'id'+idx;
  244. that.current = idx;
  245. that.getVipMoneyT(data[idx].level)
  246. }
  247. })
  248. }
  249. }else{
  250. that.scrollIntoView = 0;
  251. that.current = 0;
  252. that.getVipMoneyT(data[0].level)
  253. }
  254. resolve();
  255. });
  256. })
  257. },
  258. getVipMoneyT(index) {
  259. let from = {
  260. level: index
  261. };
  262. return new Promise((resolve, reject) => {
  263. req.getRequest('/api/levelStrategy/list', from, data => {
  264. this.vipList = data;
  265. this.money = data[0].price;
  266. this.saleMoney = data[0].originalPrice - data[0].price;
  267. });
  268. resolve();
  269. });
  270. },
  271. //购买
  272. buy() {
  273. let that = this;
  274. route.vip(
  275. {
  276. strategyId: this.checkItem.id,
  277. scene: req.getStorage('scene')
  278. },
  279. data => {
  280. h5util.jumpPay({orderId:data.id,status:data.status,money:this.money,payType:'vip'})
  281. uni.hideLoading();
  282. // route.vipPay(data.id, data.status, this.money, res => {
  283. // uni.hideLoading();
  284. // app.globalData.reLaunchTo('pages/index/index');
  285. // });
  286. }
  287. );
  288. },
  289. jumpUrl(url){
  290. uni.navigateTo({
  291. url: url
  292. })
  293. }
  294. }
  295. };
  296. </script>
  297. <style>
  298. @import "./index.css"
  299. </style>