detail.vue 10 KB

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