detail.vue 9.8 KB

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