detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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><u-tabs :list="list" item-width="50%" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  20. </view>
  21. <u-line color="#D6D6DB" />
  22. </view>
  23. <view class="intro" v-if="current == 0">
  24. <view class="content" style="padding:10rpx;"><rich-text :nodes="goodsData.mobileDetailHtml"></rich-text></view>
  25. </view>
  26. <view class="title-list" v-if="current == 1">
  27. <view class="content">
  28. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  29. <template v-if="item1.type == 1">
  30. <view class="moduleItem" @click="clickModule" :data-id="item1.majorId" :data-index="index1">
  31. <view class="courseName">{{ item1.name }}</view>
  32. <view>
  33. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  34. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  35. </view>
  36. </view>
  37. <template v-if="item1.showList">
  38. <view v-for="(item2, index2) in item1.list" :key="index2">
  39. <view class="section" @click="changeItem" :data-index1="index1" :data-index2="index2" :data-id="item2.chapterExamId" :data-type="item1.type">
  40. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  41. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  42. <!-- <u-icon v-if="!item2.showList" name="arrow-up"></u-icon>
  43. <u-icon v-if="item2.showList" name="arrow-down"></u-icon> -->
  44. <text style="margin-left:34rpx;">{{ item2.name }}</text>
  45. </view>
  46. <view v-if="item2.showList">
  47. <view class="article" :class="{ active: showTest(article.examId) }" v-for="(article, index3) in item2.list" :key="index3">
  48. <view class="flex_auto">{{ article.examName }}</view>
  49. <navigator hover-class="none" :url="'/pages2/bank/questionBankTest?id=' + article.examId + '&num=' + showTest(article.examId).num">
  50. <view class="btn" v-if="showTest(article.examId)">试做</view>
  51. </navigator>
  52. </view>
  53. </view>
  54. <u-line></u-line>
  55. </view>
  56. </template>
  57. </template>
  58. <template v-if="item1.type == 2">
  59. <view class="section" :data-index1="index1" :data-id="item1.majorId" @click="changeItem" :data-type="item1.type">
  60. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  61. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  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="index2" 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.examId+'&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. computed: { ...mapGetters(['userInfo']) },
  124. onLoad(option) {
  125. this.id = option.id;
  126. this.getDetail();
  127. this.goodsBankList();
  128. },
  129. onShow() {},
  130. methods: {
  131. getDetail() {
  132. this.$api.commonGoodsDetail(this.id).then(res => {
  133. if (res.data.data.mobileDetailHtml) {
  134. res.data.data.mobileDetailHtml = res.data.data.mobileDetailHtml.replace(/<img/gi, '<img style="max-width:100%;"');
  135. }
  136. this.goodsData = res.data.data;
  137. this.goodsExamConfig = JSON.parse(res.data.data.goodsExamConfig);
  138. });
  139. },
  140. goodsBankList() {
  141. this.$api
  142. .goodsBankList({
  143. goodsId: this.id
  144. })
  145. .then(res => {
  146. console.log(res);
  147. this.bankList = res.data.data;
  148. });
  149. },
  150. goodsChapterList(bank, id) {
  151. this.$api
  152. .goodsChapterList({
  153. moduleExamId: id
  154. })
  155. .then(res => {
  156. this.$set(bank, 'list', res.data.data);
  157. });
  158. },
  159. showTest(id) {
  160. return this.goodsExamConfig.find(item => item.examId == id);
  161. },
  162. clickModule(e) {
  163. let index = e.currentTarget.dataset.index;
  164. let id = e.currentTarget.dataset.id;
  165. if (this.bankList[index].list) {
  166. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  167. return;
  168. }
  169. this.$api
  170. .goodsChapterList({
  171. moduleExamId: id
  172. })
  173. .then(res => {
  174. this.$set(this.bankList[index], 'showList', true);
  175. this.$set(this.bankList[index], 'list', res.data.data);
  176. });
  177. },
  178. buy() {
  179. if (this.$method.isGoLogin()) {
  180. return;
  181. }
  182. this.$navTo.togo('/pages2/order/confirm_list?id=' + this.id);
  183. },
  184. addCart() {
  185. if (this.$method.isGoLogin()) {
  186. return;
  187. }
  188. let self = this;
  189. this.$api.addCart({ goodsId: this.id }).then(res => {
  190. if (res.data.code == 200) {
  191. uni.setStorageSync('updateCart', 1); //提醒刷新购物车
  192. uni.showToast({
  193. title: '添加成功'
  194. });
  195. } else {
  196. this.$u.toast(res.data.msg);
  197. }
  198. });
  199. },
  200. open(item) {
  201. item.showChildren = !item.showChildren;
  202. },
  203. change(index) {
  204. this.current = index;
  205. },
  206. changeItem(e) {
  207. let index1 = e.currentTarget.dataset.index1;
  208. let index2 = e.currentTarget.dataset.index2;
  209. let id = e.currentTarget.dataset.id;
  210. let type = e.currentTarget.dataset.type;
  211. if (type == 1) {
  212. if (this.bankList[index1].list[index2].list) {
  213. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  214. return;
  215. }
  216. this.$api
  217. .goodsExamList({
  218. chapterExamId: id
  219. })
  220. .then(res => {
  221. this.$set(this.bankList[index1].list[index2], 'showList', true);
  222. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  223. });
  224. } else if (type == 2) {
  225. if (this.bankList[index1].list) {
  226. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  227. return;
  228. }
  229. this.$api
  230. .goodsExamList({
  231. chapterExamId: id
  232. })
  233. .then(res => {
  234. this.$set(this.bankList[index1], 'showList', true);
  235. this.$set(this.bankList[index1], 'list', res.data.data);
  236. });
  237. }
  238. }
  239. }
  240. };
  241. </script>
  242. <style>
  243. page {
  244. background-color: #eaeef1;
  245. }
  246. </style>
  247. <style lang="scss" scope>
  248. .courseName {
  249. white-space: nowrap;
  250. overflow: hidden;
  251. text-overflow: ellipsis;
  252. }
  253. .icon_up {
  254. width: 32rpx;
  255. height: 32rpx;
  256. }
  257. .intro {
  258. background: #eaeef1;
  259. padding: 16rpx 16rpx 124rpx;
  260. .content {
  261. background: #fff;
  262. border-radius: 16rpx;
  263. .top {
  264. border-radius: 16rpx;
  265. padding: 32rpx 28rpx 16rpx;
  266. font-size: 30rpx;
  267. color: #333333;
  268. }
  269. .img {
  270. width: 100%;
  271. }
  272. }
  273. }
  274. .moduleItem {
  275. height: 80rpx;
  276. color: #333333;
  277. font-size: 32rpx;
  278. line-height: 80rpx;
  279. font-weight: bold;
  280. display: flex;
  281. justify-content: space-between;
  282. }
  283. .title-list {
  284. background: #eaeef1;
  285. padding: 16rpx 16rpx 124rpx;
  286. .content {
  287. .list {
  288. background: #fff;
  289. margin-bottom: 30rpx;
  290. overflow: hidden;
  291. border-radius: 16rpx;
  292. padding: 10rpx 16rpx;
  293. .module {
  294. font-size: 32rpx;
  295. color: #333333;
  296. .icon {
  297. margin-right: 10rpx;
  298. }
  299. }
  300. .section {
  301. font-size: 30rpx;
  302. color: #333;
  303. white-space: nowrap;
  304. overflow: hidden;
  305. text-overflow: ellipsis;
  306. margin: 20rpx 0;
  307. display: flex;
  308. align-items: center;
  309. }
  310. .article {
  311. height: 80rpx;
  312. display: flex;
  313. align-items: center;
  314. margin-left: 64rpx;
  315. font-size: 24rpx;
  316. color: #666666;
  317. border-bottom: 1rpx solid #eeeeee;
  318. display: flex;
  319. .flex_auto {
  320. flex: 1;
  321. }
  322. &:nth-last-of-type(1) {
  323. border: 0;
  324. }
  325. &.active {
  326. color: #007aff;
  327. .btn {
  328. width: 96rpx;
  329. height: 48rpx;
  330. line-height: 48rpx;
  331. text-align: center;
  332. color: #fff;
  333. font-size: 30rpx;
  334. border-radius: 24rpx;
  335. background: #007aff;
  336. margin-left: 36rpx;
  337. border-radius: 24rpx;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. .btn2 {
  345. width: 200rpx;
  346. height: 64rpx;
  347. background: linear-gradient(0deg, #ffb102, #fd644f);
  348. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  349. border-radius: 32rpx;
  350. line-height: 64rpx;
  351. text-align: center;
  352. }
  353. .btn1 {
  354. width: 200rpx;
  355. height: 64rpx;
  356. background: linear-gradient(0deg, #015eea, #00c0fa);
  357. border-radius: 32rpx;
  358. line-height: 64rpx;
  359. text-align: center;
  360. margin-right: 20rpx;
  361. }
  362. .bottomBox {
  363. position: fixed;
  364. bottom: 0;
  365. width: 100%;
  366. left: 0;
  367. height: 98rpx;
  368. background-color: #ffffff;
  369. display: flex;
  370. justify-content: space-between;
  371. align-items: center;
  372. padding: 0 30rpx;
  373. }
  374. .blackFont {
  375. color: #333333;
  376. margin: 0 4rpx;
  377. }
  378. .wk_icon {
  379. width: 24rpx;
  380. height: 24rpx;
  381. margin-right: 12rpx;
  382. }
  383. .noteTag {
  384. ont-size: 24rpx;
  385. font-family: PingFang SC;
  386. font-weight: 500;
  387. color: #999999;
  388. align-items: center;
  389. }
  390. .priceTag {
  391. font-size: 30rpx;
  392. font-family: PingFang SC;
  393. font-weight: bold;
  394. color: #ff2d55;
  395. }
  396. .titleTag {
  397. font-size: 32rpx;
  398. font-weight: bold;
  399. color: #333333;
  400. margin-left: 8rpx;
  401. }
  402. .yearTag {
  403. width: 80rpx;
  404. height: 32rpx;
  405. background: #ebf5ff;
  406. border: 2rpx solid #007aff;
  407. border-radius: 16rpx;
  408. font-size: 24rpx;
  409. color: #007aff;
  410. text-align: center;
  411. line-height: 32rpx;
  412. }
  413. .itemBox {
  414. background: #ffffff;
  415. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  416. border-radius: 24rpx;
  417. width: 100%;
  418. padding: 20rpx;
  419. margin-bottom: 20rpx;
  420. }
  421. </style>