detail.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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. <view class="top">本题库为广东省建筑施工企业安全生产管理人员安全生产考试第三批参考题库(可两行)</view>
  28. <image class="img" src="/static/intro.png" ></image>
  29. </view>
  30. </view>
  31. <view class="title-list" v-if="current == 1">
  32. <view class="content">
  33. <view class="list" v-for="(item1,index1) in bankList">
  34. <template v-if="item1.type==3">
  35. <view class="module" @click="clickModule" :data-id="item1.id" :data-index="index1">
  36. {{item1.name}} {{item1.subjectName}}
  37. </view>
  38. <template v-if="item1.showList">
  39. <view class="section" v-for="(item2,index2) in item1.list" @click="changeItem" :data-index1="index1" :data-index2="index2" :data-id="item2.id" :data-type="item1.type">
  40. <u-icon name="arrow-down" v-if="item2.showList"></u-icon>
  41. <u-icon name="arrow-up" v-if="!item2.showList"></u-icon>
  42. {{item2.name}}
  43. </view>
  44. <view v-if="item2.showList" >
  45. <view class="article" v-for="(article,index1) in item2.list">
  46. <view class="flex">{{article.name}}</view>
  47. <navigator url="/pages2/bank/questionBankTest?id="+article.id+"">
  48. <view v-if="index1 == 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" @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. 2Z106010 施工承发包的模式-2Z106020 施工合同...
  59. </view>
  60. <view v-if="item1.showList" >
  61. <view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in item1.list">
  62. 施工承发包模式-施工合同与物资采购合同二
  63. <navigator url="/pages2/bank/questionBankTest">
  64. <view v-if="index1 == 0" class="btn">试做</view>
  65. </navigator>
  66. </view>
  67. </view>
  68. </template>
  69. <template v-if="item1.type ==1">
  70. <view class="article" :class="{active:index1 == 0}" v-for="(article,index1) in 3">
  71. 施工承发包模式-施工合同与物资采购合同二
  72. <navigator url="/pages2/bank/questionBankTest">
  73. <view v-if="index1 == 0" 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. res.data.data.forEach(bank => {
  140. // if(bank.type == 3) {
  141. // this.goodsChapterList(bank,bank.id)
  142. // }
  143. })
  144. })
  145. },
  146. goodsChapterList(bank,id) {
  147. this.$api.goodsChapterList({
  148. moduleExamId:id
  149. }).then(res => {
  150. this.$set(bank,'list',[{
  151. name:'章卷',
  152. showList:false,
  153. id:1
  154. }])
  155. })
  156. },
  157. clickModule(e) {
  158. let index = e.currentTarget.dataset.index;
  159. let id = e.currentTarget.dataset.id;
  160. console.log(this.bankList)
  161. if(this.bankList[index].list) {
  162. this.$set(this.bankList[index],'showList',!this.bankList[index].showList)
  163. return;
  164. }
  165. this.$api.goodsChapterList({
  166. moduleExamId:id
  167. }).then(res => {
  168. this.$set(this.bankList[index],'showList',true)
  169. this.$set(this.bankList[index],'list',[{
  170. name:'章卷',
  171. showList:false,
  172. id:1
  173. }])
  174. })
  175. },
  176. buy(){
  177. if(this.$method.isGoLogin()){
  178. return
  179. }
  180. this.$navTo.togo('/pages2/order/confirm_list');
  181. },
  182. addCart(){
  183. if(this.$method.isGoLogin()){
  184. return
  185. }
  186. let self = this
  187. this.$api.addCart({goodsId:this.id}).then(res => {
  188. if(res.data.code==200){
  189. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  190. uni.showToast({
  191. title: '添加成功'
  192. });
  193. }else{
  194. this.$u.toast(res.data.msg);
  195. }
  196. });
  197. },
  198. open(item){
  199. item.showChildren = !item.showChildren
  200. },
  201. change(index){
  202. this.current = index;
  203. },
  204. changeItem(e) {
  205. let index1 = e.currentTarget.dataset.index1
  206. let index2 = e.currentTarget.dataset.index2
  207. let id = e.currentTarget.dataset.id
  208. let type = e.currentTarget.dataset.type
  209. if(type == 3) {
  210. if(this.bankList[index1].list[index2].list) {
  211. this.$set(this.bankList[index1].list[index2],'showList',!this.bankList[index1].list[index2].showList)
  212. this.$set(this.bankList[index1].list[index2],'list',[{
  213. name:'试卷',
  214. id:2,
  215. }])
  216. return;
  217. }
  218. this.$api.goodsExamList({
  219. chapterExamId:id
  220. }).then(res => {
  221. // res.data.data.forEach(item => {
  222. // item.showList = false;
  223. // })
  224. // this.bankList = res.data.data;
  225. this.$set(this.bankList[index1].list[index2],'showList',true)
  226. this.$set(this.bankList[index1].list[index2],'list',[{
  227. name:'试卷',
  228. id:2,
  229. }])
  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.goodsExamList({
  237. chapterExamId:id
  238. }).then(res => {
  239. // res.data.data.forEach(item => {
  240. // item.showList = false;
  241. // })
  242. // this.bankList = res.data.data;
  243. this.$set(this.bankList[index1],'showList',true)
  244. this.$set(this.bankList[index1],'list',[{
  245. name:'试卷',
  246. id:2,
  247. }])
  248. })
  249. }
  250. }
  251. }
  252. };
  253. </script>
  254. <style >
  255. page{
  256. background-color: #EAEEF1;
  257. }
  258. </style>
  259. <style lang="scss" scope>
  260. .intro {
  261. background: #EAEEF1;
  262. padding:16rpx 16rpx 124rpx;
  263. .content {
  264. background:#fff;
  265. border-radius: 16rpx;;
  266. .top {
  267. border-radius: 16rpx;
  268. padding:32rpx 28rpx 16rpx;
  269. font-size: 30rpx;
  270. color: #333333;
  271. }
  272. .img {
  273. width:100%;
  274. }
  275. }
  276. }
  277. .title-list {
  278. background: #EAEEF1;
  279. padding:16rpx 16rpx 124rpx;
  280. .content {
  281. .list {
  282. background:#fff;
  283. margin-bottom:30rpx;
  284. overflow: hidden;
  285. border-radius: 16rpx;
  286. padding:10rpx 16rpx;
  287. .module {
  288. font-size: 30rpx;
  289. color: #333333;
  290. }
  291. .section {
  292. padding:30rpx 0;
  293. border-bottom: 1rpx solid #EEEEEE;
  294. font-size: 24rpx;
  295. color: #666666;
  296. }
  297. .article {
  298. height:80rpx;
  299. display: flex;
  300. align-items: center;
  301. margin-left:88rpx;
  302. font-size: 24rpx;
  303. color: #666666;
  304. border-bottom: 1rpx solid #EEEEEE;
  305. display: flex;
  306. .flex_auto{
  307. flex:1;
  308. }
  309. &:nth-last-of-type(1) {
  310. border:0;
  311. }
  312. &.active {
  313. color:#007AFF;
  314. .btn {
  315. width: 96rpx;
  316. height: 48rpx;
  317. line-height: 48rpx;
  318. text-align: center;
  319. color:#fff;
  320. font-size: 30rpx;
  321. border-radius:24rpx;
  322. background: #007AFF;
  323. margin-left:36rpx;
  324. border-radius: 24rpx;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. .btn2{
  332. width: 200rpx;
  333. height: 64rpx;
  334. background: linear-gradient(0deg, #FFB102, #FD644F);
  335. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  336. border-radius: 32rpx;
  337. line-height: 64rpx;
  338. text-align: center;
  339. }
  340. .btn1{
  341. width: 200rpx;
  342. height: 64rpx;
  343. background: linear-gradient(0deg, #015EEA, #00C0FA);
  344. border-radius: 32rpx;
  345. line-height: 64rpx;
  346. text-align: center;
  347. margin-right: 20rpx;
  348. }
  349. .bottomBox{
  350. position: fixed;
  351. bottom: 0;
  352. width: 100%;
  353. left: 0;
  354. height:98rpx ;
  355. background-color: #FFFFFF;
  356. display: flex;
  357. justify-content: space-between;
  358. align-items: center;
  359. padding: 0 30rpx;
  360. }
  361. .blackFont{
  362. color: #333333;
  363. margin: 0 4rpx;
  364. }
  365. .wk_icon{
  366. width: 24rpx;
  367. height: 24rpx;
  368. margin-right: 12rpx;
  369. }
  370. .noteTag{
  371. ont-size: 24rpx;
  372. font-family: PingFang SC;
  373. font-weight: 500;
  374. color: #999999;
  375. align-items: center;
  376. }
  377. .priceTag{
  378. font-size: 30rpx;
  379. font-family: PingFang SC;
  380. font-weight: bold;
  381. color: #FF2D55;
  382. }
  383. .titleTag{
  384. font-size: 32rpx;
  385. font-weight: bold;
  386. color: #333333;
  387. margin-left: 8rpx;
  388. }
  389. .yearTag{
  390. width: 80rpx;
  391. height: 32rpx;
  392. background: #EBF5FF;
  393. border: 2rpx solid #007AFF;
  394. border-radius: 16rpx;
  395. font-size: 24rpx;
  396. color: #007AFF;
  397. text-align: center;
  398. line-height: 32rpx;
  399. }
  400. .itemBox{
  401. background: #FFFFFF;
  402. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  403. border-radius: 24rpx;
  404. width: 100%;
  405. padding: 20rpx;
  406. margin-bottom: 20rpx;
  407. }
  408. </style>