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