detail.vue 10 KB

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