detail.vue 11 KB

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