mallPage.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="ezy-mall-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">鹅状元进阶营</text>
  6. </view>
  7. <view class="ezy-tab-border">
  8. <uni-segmented-control :current="productData.current" :values="productData.items" active-color="#3A7FE9"
  9. @clickItem="onChangeTab" class="ezy-tab-box" />
  10. <view>
  11. <view v-if="productData.current === 0">
  12. <scroll-view scroll-y="true" :scroll-into-view="scrollIntoId" class="order-scroll-view">
  13. <!--数学-->
  14. <uni-list>
  15. <uni-list-item v-for="item in productData.list" class="mall-list-item">
  16. <view :id="'item-' + item.id">
  17. <template v-slot:body>
  18. <view class="mall-content-box">
  19. <!-- 需要换成从接口中取得 wgy -->
  20. <img :src='item.cover' class="mall-image" />
  21. <view class="content-body-box">
  22. <view class="content-name">
  23. <view class="name-text">{{item.name}}</view>
  24. </view>
  25. <view class="content-text">{{item.intro}}</view>
  26. <view class="content-row">
  27. <view class="content-yuanjia">原价:{{item.yuanjia}}</view>
  28. <view class="shop-car-box">
  29. <!-- 购物车上的对号需控制 wgy-->
  30. <icon class="car-change"></icon>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="mall-bottom-row">
  36. <!-- 组合课程显示课程包明细按钮 wgy -->
  37. <view v-if="item.type ==1" class="kcb-btn" @click="productBtn">课程包明细<icon>
  38. </icon>
  39. </view>
  40. <view class="hdj-text">活动价:{{item.xianjia}}</view>
  41. </view>
  42. </template>
  43. </view>
  44. </uni-list-item>
  45. </uni-list>
  46. </scroll-view>
  47. </view>
  48. <view v-if="productData.current === 1">
  49. <view>英语</view>
  50. </view>
  51. <!-- <view v-if="productData.current === 2">
  52. <view>语文</view>
  53. </view> -->
  54. </view>
  55. </view>
  56. <view class="footer-mall-pay-box">
  57. <view class="mall-left-box" @click="detailBtn">
  58. <!-- 需要换成从接口中取得 wgy -->
  59. <view class="price-icon-box">
  60. <text class="red-price fh-text">¥</text>
  61. <text class="red-price">1999.8</text>明细
  62. <icon :class="mxjtClass"></icon>
  63. </view>
  64. <view>购买即同意虚拟产品不支持退订</view>
  65. </view>
  66. <!-- 微信 -->
  67. <view class="pay-status-box" v-if="showPayWay" @click="switchPayWay">
  68. <icon class="wx-icon"></icon>微信
  69. </view>
  70. <!-- 支付宝 -->
  71. <view class="pay-status-box" v-if="!showPayWay" @click="switchPayWay">
  72. <icon class="zfb-icon"></icon>支付宝
  73. </view>
  74. <!-- 苹果 -->
  75. <view class="pay-status-box apple-status-box" v-if="false">
  76. <icon class="apple-icon"></icon>apple
  77. </view>
  78. <view class="pay-btn">立即支付</view>
  79. </view>
  80. <detail-dialog ref="mallDetailPopup" @payBtn="payBtn"></detail-dialog>
  81. <product-dialog ref="mallProductPopup" @payBtn="payBtn"></product-dialog>
  82. </view>
  83. </template>
  84. <script setup>
  85. import {
  86. reactive,
  87. nextTick,
  88. ref
  89. } from "vue";
  90. import {
  91. getMallist
  92. } from "@/api/productMall.js";
  93. import {
  94. onLoad
  95. } from "@dcloudio/uni-app";
  96. import {
  97. toast,
  98. getUserIdentity
  99. } from "@/utils/common";
  100. import cacheManager from '@/utils/cacheManager.js';
  101. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  102. import detailDialog from './detailDialog.vue'
  103. import productDialog from './productDialog.vue'
  104. const showPayWay = ref(true)
  105. const showDetail = ref(false)
  106. const mxjtClass = ref('mxjt-sq-icon')
  107. const mallDetailPopup = ref(null);
  108. const mallProductPopup = ref(null);
  109. let scrollIntoId = ref(null)
  110. const productData = reactive({
  111. items: ['数学', '英语'],
  112. current: 1,
  113. from: '',
  114. cardId: '',
  115. list: []
  116. })
  117. function switchPayWay() {
  118. showPayWay.value = !showPayWay.value
  119. }
  120. function productBtn() {
  121. mallProductPopup.value.detailShow();
  122. }
  123. function detailBtn() {
  124. showDetail.value = !showDetail.value;
  125. if (showDetail.value) {
  126. mxjtClass.value = 'mxjt-zk-icon';
  127. mallDetailPopup.value.detailShow();
  128. } else {
  129. mxjtClass.value = 'mxjt-sq-icon';
  130. mallDetailPopup.value.detailCloseBtn();
  131. }
  132. }
  133. function handlePay(item) {
  134. uni.redirectTo({
  135. url: `/pages/pay/svip?cardId=${item.cardId}&formPage=my&orderId=${item.id}`
  136. })
  137. }
  138. function onChangeTab(e) {
  139. console.log('e', e);
  140. productData.current = e.currentIndex
  141. getMore()
  142. }
  143. function getMore() {
  144. const opt = {
  145. subjectId: productData.current + 1
  146. }
  147. getMallist(opt).then(res => {
  148. if (res.code == 0) {
  149. productData.list = res.data
  150. nextTick(() => {
  151. scrollToIdFun(productData.cardId)
  152. })
  153. }
  154. }).catch(err => {
  155. toast("获取产品数据失败")
  156. return false
  157. })
  158. }
  159. function scrollToIdFun(targetId) {
  160. const index = productData.list.findIndex(item => item.id == targetId)
  161. console.log('index', index);
  162. if (index > -1) {
  163. // 安卓设备需要双保险
  164. scrollIntoId.value = `item-${targetId}`
  165. setTimeout(() => {
  166. scrollIntoId.value = `item-${targetId}`
  167. }, 300)
  168. }
  169. }
  170. function goBack() {
  171. if (productData.from == 'daoPage') {
  172. uni.redirectTo({
  173. url: '/pages/study/index'
  174. })
  175. } else {
  176. uni.redirectTo({
  177. url: '/pages/my/index'
  178. })
  179. }
  180. }
  181. onLoad((options) => {
  182. productData.current = Number(options.subjectId) - 1
  183. productData.cardId = options.cardId
  184. productData.from = options.from
  185. getMore();
  186. })
  187. </script>
  188. <style>
  189. </style>