detail.vue 10.0 KB

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