detail.vue 11 KB

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