detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view>
  3. <view style="background-color: #FFFFFF;">
  4. <view >
  5. <image :src="$method.splitImgHost(goodsData.coverUrl, true)" style="width: 100%;"></image>
  6. <view style="padding:20rpx">
  7. <view style="display: flex;margin-top: 13rpx;">
  8. <view class="yearTag" v-if="goodsData.year">{{goodsData.year}}</view>
  9. <view class="titleTag">{{goodsData.goodsName}}</view>
  10. </view>
  11. <!-- <view style="display: flex;justify-content: space-between;margin-top: 13rpx;" v-if="false">
  12. <view class="noteTag"><image src="/static/icon/wk_icon1.png" class="wk_icon"></image>
  13. 共 <text class="blackFont">{{goodsData.updateTime}}</text> 张卷 <text class="blackFont">1200</text> 道题 </view>
  14. </view> -->
  15. </view>
  16. </view>
  17. <u-line color="#D6D6DB" />
  18. <view>
  19. <view>
  20. <u-tabs :list="list" item-width="50%" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs>
  21. </view>
  22. </view>
  23. <u-line color="#D6D6DB" />
  24. </view>
  25. <view class="intro" v-if="current == 0">
  26. <view class="content">
  27. <rich-text :nodes="goodsData.mobileDetailHtml"></rich-text>
  28. </view>
  29. </view>
  30. <view class="title-list" v-if="current == 1">
  31. <view class="content">
  32. <view class="list" v-for="(item1,index1) in bankList" :key="index1">
  33. <template v-if="item1.type==1">
  34. <view class="moduleItem" @click="clickModule" :data-id="item1.majorId" :data-index="index1">
  35. <view class="courseName">{{item1.name}}</view>
  36. <view>
  37. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  38. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  39. </view>
  40. </view>
  41. <template v-if="item1.showList">
  42. <view v-for="(item2,index2) in item1.list" :key="index2" >
  43. <view class="section" @click="changeItem" :data-index1="index1" :data-index2="index2" :data-id="item2.chapterExamId" :data-type="item1.type">
  44. <u-icon v-if="!item2.showList" name="arrow-up"></u-icon>
  45. <u-icon v-if="item2.showList" name="arrow-down"></u-icon>
  46. <text style="margin-left:34rpx;">{{ item2.name }}</text>
  47. </view>
  48. <view v-if="item2.showList">
  49. <view class="article" :class="{active:showTest(article.examId)}" v-for="(article,index3) in item2.list" :key="index3">
  50. <view class="flex_auto">{{article.examName}}</view>
  51. <navigator hover-class="none" :url="'/pages2/bank/questionBankTest?id='+article.examId+'&num='+showTest(article.examId).num">
  52. <view class="btn" v-if="showTest(article.examId)">试做</view>
  53. </navigator>
  54. </view>
  55. </view>
  56. <u-line></u-line>
  57. </view>
  58. </template>
  59. </template>
  60. <template v-if="item1.type ==2">
  61. <view class="section" :data-index1="index1" :data-id="item1.majorId" @click="changeItem" :data-type="item1.type">
  62. <u-icon v-if="!item1.showList" name="arrow-up"></u-icon>
  63. <u-icon v-if="item1.showList" name="arrow-down"></u-icon>
  64. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  65. </view>
  66. <view v-if="item1.showList" >
  67. <view class="article" :class="{active:showTest(article.examId)}" :key="index3" v-for="(article,index2) in item1.list">
  68. <view class="flex_auto">{{item1.name}}</view>
  69. <navigator hover-class="none" :url="'/pages2/bank/questionBankTest?id='+article.majorId+'&num='+showTest(article.examId).num">
  70. <view class="btn" v-if="showTest(article.examId)">试做</view>
  71. </navigator>
  72. </view>
  73. </view>
  74. </template>
  75. <template v-if="item1.type ==3">
  76. <view class="article" :class="{active:showTest(item1.majorId)}" >
  77. <view class="flex_auto">{{item1.name}}</view>
  78. <navigator hover-class="none" :url="'/pages2/bank/questionBankTest?id='+item1.majorId+'&num='+showTest(item1.majorId).num">
  79. <view class="btn" v-if="showTest(item1.majorId)">试做</view>
  80. </navigator>
  81. </view>
  82. </template>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="bottomBox">
  87. <view class="priceTag">¥ {{goodsData.standPrice}}</view>
  88. <view style="display: flex;color: #FFFFFF;align-items: center;">
  89. <view class="btn1" @click="addCart">加购物车</view>
  90. <view class="btn2" @click="buy">立即购买</view>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import { mapGetters } from 'vuex';
  97. export default {
  98. data() {
  99. return {
  100. list: [
  101. {
  102. name: '详情'
  103. },
  104. {
  105. name: '大纲'
  106. }
  107. ],
  108. current:0,
  109. id:'',
  110. goodsData:{},
  111. bankList:[],
  112. goodsExamConfig:[],
  113. };
  114. },
  115. filters: {
  116. formatDate: function (value) {
  117. var date = new Date(value);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
  118. var Y = date.getFullYear();
  119. return Y;
  120. }
  121. },
  122. onUnload() {
  123. },
  124. computed: { ...mapGetters(['userInfo']) },
  125. onLoad(option) {
  126. console.log(option)
  127. this.id = option.id
  128. this.getDetail();
  129. this.goodsBankList()
  130. },
  131. onShow() {
  132. },
  133. methods: {
  134. getDetail(){
  135. this.$api.commonGoodsDetail(this.id).then(res => {
  136. console.log(res)
  137. this.goodsData = res.data.data;
  138. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig)
  139. })
  140. },
  141. goodsBankList() {
  142. this.$api.goodsBankList({
  143. goodsId:this.id
  144. }).then(res => {
  145. console.log(res)
  146. this.bankList = res.data.data;
  147. })
  148. },
  149. goodsChapterList(bank,id) {
  150. this.$api.goodsChapterList({
  151. moduleExamId:id
  152. }).then(res => {
  153. this.$set(bank,'list',res.data.data)
  154. })
  155. },
  156. showTest(id) {
  157. return this.goodsExamConfig.find(item => item.examId == id);
  158. },
  159. clickModule(e) {
  160. let index = e.currentTarget.dataset.index;
  161. let id = e.currentTarget.dataset.id;
  162. if(this.bankList[index].list) {
  163. this.$set(this.bankList[index],'showList',!this.bankList[index].showList)
  164. return;
  165. }
  166. this.$api.goodsChapterList({
  167. moduleExamId:id
  168. }).then(res => {
  169. this.$set(this.bankList[index],'showList',true)
  170. this.$set(this.bankList[index],'list',res.data.data)
  171. })
  172. },
  173. buy(){
  174. if(this.$method.isGoLogin()){
  175. return
  176. }
  177. this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
  178. },
  179. addCart(){
  180. if(this.$method.isGoLogin()){
  181. return
  182. }
  183. let self = this
  184. this.$api.addCart({goodsId:this.id}).then(res => {
  185. if(res.data.code==200){
  186. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  187. uni.showToast({
  188. title: '添加成功'
  189. });
  190. }else{
  191. this.$u.toast(res.data.msg);
  192. }
  193. });
  194. },
  195. open(item){
  196. item.showChildren = !item.showChildren
  197. },
  198. change(index){
  199. this.current = index;
  200. },
  201. changeItem(e) {
  202. let index1 = e.currentTarget.dataset.index1
  203. let index2 = e.currentTarget.dataset.index2
  204. let id = e.currentTarget.dataset.id
  205. let type = e.currentTarget.dataset.type
  206. if(type == 1) {
  207. if(this.bankList[index1].list[index2].list) {
  208. this.$set(this.bankList[index1].list[index2],'showList',!this.bankList[index1].list[index2].showList)
  209. return;
  210. }
  211. this.$api.goodsExamList({
  212. chapterExamId:id
  213. }).then(res => {
  214. this.$set(this.bankList[index1].list[index2],'showList',true)
  215. this.$set(this.bankList[index1].list[index2],'list',res.data.data)
  216. })
  217. } else if(type == 2) {
  218. if(this.bankList[index1].list) {
  219. this.$set(this.bankList[index1],'showList',!this.bankList[index1].showList)
  220. return;
  221. }
  222. this.$api.goodsExamList({
  223. chapterExamId:id
  224. }).then(res => {
  225. this.$set(this.bankList[index1],'showList',true)
  226. this.$set(this.bankList[index1],'list',res.data.data)
  227. })
  228. }
  229. }
  230. }
  231. };
  232. </script>
  233. <style >
  234. page{
  235. background-color: #EAEEF1;
  236. }
  237. </style>
  238. <style lang="scss" scope>
  239. .courseName{
  240. white-space:nowrap;
  241. overflow:hidden;
  242. text-overflow:ellipsis;
  243. }
  244. .icon_up{
  245. width: 32rpx;
  246. height: 32rpx;
  247. }
  248. .intro {
  249. background: #EAEEF1;
  250. padding:16rpx 16rpx 124rpx;
  251. .content {
  252. background:#fff;
  253. border-radius: 16rpx;;
  254. .top {
  255. border-radius: 16rpx;
  256. padding:32rpx 28rpx 16rpx;
  257. font-size: 30rpx;
  258. color: #333333;
  259. }
  260. .img {
  261. width:100%;
  262. }
  263. }
  264. }
  265. .moduleItem{
  266. height: 80rpx;
  267. color: #333333;
  268. font-size: 32rpx;
  269. line-height: 80rpx;
  270. font-weight: bold;
  271. display: flex;
  272. justify-content: space-between;
  273. }
  274. .title-list {
  275. background: #EAEEF1;
  276. padding:16rpx 16rpx 124rpx;
  277. .content {
  278. .list {
  279. background:#fff;
  280. margin-bottom:30rpx;
  281. overflow: hidden;
  282. border-radius: 16rpx;
  283. padding:10rpx 16rpx;
  284. .module {
  285. font-size: 32rpx;
  286. color: #333333;
  287. .icon {
  288. margin-right:10rpx;
  289. }
  290. }
  291. .section {
  292. font-size: 30rpx;
  293. color: #333;
  294. white-space:nowrap;
  295. overflow:hidden;
  296. text-overflow:ellipsis;
  297. margin: 20rpx 0;
  298. display: flex;
  299. align-items: center;
  300. }
  301. .article {
  302. height:80rpx;
  303. display: flex;
  304. align-items: center;
  305. margin-left:64rpx;
  306. font-size: 24rpx;
  307. color: #666666;
  308. border-bottom: 1rpx solid #EEEEEE;
  309. display: flex;
  310. .flex_auto{
  311. flex:1;
  312. }
  313. &:nth-last-of-type(1) {
  314. border:0;
  315. }
  316. &.active {
  317. color:#007AFF;
  318. .btn {
  319. width: 96rpx;
  320. height: 48rpx;
  321. line-height: 48rpx;
  322. text-align: center;
  323. color:#fff;
  324. font-size: 30rpx;
  325. border-radius:24rpx;
  326. background: #007AFF;
  327. margin-left:36rpx;
  328. border-radius: 24rpx;
  329. }
  330. }
  331. }
  332. }
  333. }
  334. }
  335. .btn2{
  336. width: 200rpx;
  337. height: 64rpx;
  338. background: linear-gradient(0deg, #FFB102, #FD644F);
  339. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  340. border-radius: 32rpx;
  341. line-height: 64rpx;
  342. text-align: center;
  343. }
  344. .btn1{
  345. width: 200rpx;
  346. height: 64rpx;
  347. background: linear-gradient(0deg, #015EEA, #00C0FA);
  348. border-radius: 32rpx;
  349. line-height: 64rpx;
  350. text-align: center;
  351. margin-right: 20rpx;
  352. }
  353. .bottomBox{
  354. position: fixed;
  355. bottom: 0;
  356. width: 100%;
  357. left: 0;
  358. height:98rpx ;
  359. background-color: #FFFFFF;
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. padding: 0 30rpx;
  364. }
  365. .blackFont{
  366. color: #333333;
  367. margin: 0 4rpx;
  368. }
  369. .wk_icon{
  370. width: 24rpx;
  371. height: 24rpx;
  372. margin-right: 12rpx;
  373. }
  374. .noteTag{
  375. ont-size: 24rpx;
  376. font-family: PingFang SC;
  377. font-weight: 500;
  378. color: #999999;
  379. align-items: center;
  380. }
  381. .priceTag{
  382. font-size: 30rpx;
  383. font-family: PingFang SC;
  384. font-weight: bold;
  385. color: #FF2D55;
  386. }
  387. .titleTag{
  388. font-size: 32rpx;
  389. font-weight: bold;
  390. color: #333333;
  391. margin-left: 8rpx;
  392. }
  393. .yearTag{
  394. width: 80rpx;
  395. height: 32rpx;
  396. background: #EBF5FF;
  397. border: 2rpx solid #007AFF;
  398. border-radius: 16rpx;
  399. font-size: 24rpx;
  400. color: #007AFF;
  401. text-align: center;
  402. line-height: 32rpx;
  403. }
  404. .itemBox{
  405. background: #FFFFFF;
  406. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  407. border-radius: 24rpx;
  408. width: 100%;
  409. padding: 20rpx;
  410. margin-bottom: 20rpx;
  411. }
  412. </style>