detail.vue 11 KB

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