detail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view>
  3. <view class="videoBox" >
  4. <view >
  5. <image :src="$method.splitImgHost(detail.coverUrl)" style="height: 460rpx;width: 100%;"></image>
  6. <view style="padding:20rpx;height: 120rpx;">
  7. <view style="display: flex;">
  8. <view class="yearTag">{{detail.year}}</view>
  9. <view class="titleTag">{{detail.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">6</text> 科 <text class="blackFont">120</text> 节 <text class="blackFont">60</text> 学时</view>
  14. </view>
  15. </view>
  16. </view>
  17. <u-line color="#D6D6DB" />
  18. <view style="height: 80rpx;">
  19. <view style="width: 160px;margin: 0 auto;"><u-tabs :list="list" item-width="150" font-size="24" bar-width="110" :current="current" @change="change" active-color="#007AFF"></u-tabs></view>
  20. </view>
  21. </view>
  22. <view style="padding: 20rpx;position: relative;top: 680rpx;" v-show="current==0">
  23. <view class="content">
  24. <view v-html="detail.mobileDetailHtml"></view>
  25. </view>
  26. </view>
  27. <view style="padding: 20rpx;padding-bottom: 100rpx;position: relative;top: 680rpx;" v-show="current==1">
  28. <view >
  29. <view v-for="(item,index) in courseList" >
  30. <view class="courseItemBox" >
  31. <view class="courseItem" @click="openCourse(item)">
  32. <view class="courseName">{{item.courseName}}</view>
  33. <view>
  34. <image src="/static/icon/up.png" class="icon_up" v-if="item.down"></image>
  35. <image src="/static/icon/down.png" class="icon_up" v-if="!item.down"></image>
  36. </view>
  37. </view>
  38. <view v-show="!item.down">
  39. <view v-for="(itemM,indexM) in menuList" >
  40. <courseModule v-if="itemM.type==1" :menuItem="itemM"></courseModule>
  41. <courseChapter v-if="itemM.type==2" :menuItem="itemM"></courseChapter>
  42. <courseSection v-if="itemM.type==3" :menuItem="itemM"></courseSection>
  43. <u-line></u-line>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="bottomBox">
  51. <view class="priceTag">¥ {{detail.standPrice}}</view>
  52. <view style="display: flex;color: #FFFFFF;align-items: center;">
  53. <view class="btn1" @click="addCart">加购物车</view>
  54. <view class="btn2" @click="buy">立即购买 </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import courseModule from '@/pages2/components/course/courseModule.vue';
  61. import courseChapter from '@/pages2/components/course/courseChapter.vue';
  62. import courseSection from '@/pages2/components/course/courseSection.vue';
  63. import { mapGetters } from 'vuex';
  64. export default {
  65. components: {
  66. courseModule,
  67. courseChapter,
  68. courseSection
  69. },
  70. data() {
  71. return {
  72. id:0,
  73. list: [
  74. {
  75. name: '详情'
  76. },
  77. {
  78. name: '大纲'
  79. }
  80. ],
  81. current:0,
  82. detail:{},
  83. courseList:[],
  84. menuList:[]
  85. };
  86. },
  87. onUnload() {
  88. },
  89. computed: { ...mapGetters(['userInfo','goodsAuditionConfigIdList']) },
  90. onLoad(option) {
  91. this.id = option.id;
  92. this.getDetail()
  93. this.goodsCourseList()
  94. },
  95. onShow() {
  96. },
  97. methods: {
  98. openCourse(item){
  99. item.down = !item.down
  100. if(!item.down&&this.menuList.length==0){
  101. this.getMenuList(item.courseId)
  102. }
  103. },
  104. addShopCart() {
  105. let self = this
  106. this.$api.addCart({goodsId:this.id}).then(res => {
  107. if(res.data.code==200){
  108. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  109. uni.showToast({
  110. title: '添加成功'
  111. });
  112. }else{
  113. this.$u.toast(res.data.msg);
  114. }
  115. });
  116. },
  117. goodsCourseList() {
  118. let self = this
  119. this.$api.goodsCourseList(this.id).then(res => {
  120. if(res.data.code==200){
  121. for(let i=0;i<res.data.rows.length;i++){
  122. let item = res.data.rows[i]
  123. item.down = true
  124. }
  125. self.courseList = res.data.rows
  126. }
  127. });
  128. },
  129. getMenuList(courseId) {
  130. let self = this
  131. this.$api.menuList({courseId:courseId}).then(res => {
  132. if(res.data.code==200){
  133. for(let i=0;i<res.data.rows.length;i++){
  134. let item = res.data.rows[i]
  135. item.down = true
  136. item.id = item.menuId
  137. item.name = item.menuName
  138. if(item.type==3){
  139. //判断是否试听
  140. item.tryListen = false
  141. if(self.goodsAuditionConfigIdList.indexOf(item.id)!==-1){
  142. item.tryListen = true
  143. }
  144. }
  145. }
  146. self.menuList = res.data.rows
  147. }
  148. });
  149. },
  150. getDetail() {
  151. let self = this
  152. let sectionIdList = []
  153. this.$api.goodsDetail(this.id).then(res => {
  154. if(res.data.code==200){
  155. self.detail = res.data.data
  156. if(self.detail.goodsAuditionConfig){
  157. let configList = JSON.parse(self.detail.goodsAuditionConfig)
  158. for (var itemChild of configList) {
  159. sectionIdList.push(itemChild.sectionId)//存储试听节ID
  160. }
  161. self.$store.commit('setGoodsAuditionConfigIdList', {goodsAuditionConfigIdList:sectionIdList});
  162. }
  163. }
  164. });
  165. },
  166. buy(){
  167. if(this.$method.isGoLogin()){
  168. return
  169. }
  170. this.$navTo.togo('/pages2/order/confirm_list?id='+this.id);
  171. },
  172. addCart(){
  173. if(this.$method.isGoLogin()){
  174. return
  175. }
  176. this.addShopCart()
  177. },
  178. open(item){
  179. item.showChildren = !item.showChildren
  180. },
  181. change(index){
  182. this.current = index;
  183. }
  184. }
  185. };
  186. </script>
  187. <style >
  188. page{
  189. background-color: #EAEEF1;
  190. }
  191. </style>
  192. <style scope>
  193. .courseName{
  194. white-space:nowrap;
  195. overflow:hidden;
  196. text-overflow:ellipsis;
  197. }
  198. .videoBox{
  199. position: fixed;
  200. background-color: #FFFFFF;
  201. width: 100%;
  202. height: 680rpx;
  203. z-index: 999;
  204. }
  205. .icon_up{
  206. width: 32rpx;
  207. height: 32rpx;
  208. }
  209. .contentBox{
  210. }
  211. .courseItemBox{
  212. background: #FFFFFF;
  213. border-radius: 16rpx;
  214. padding: 0 10rpx;
  215. margin-bottom: 20rpx;
  216. }
  217. .courseItem{
  218. height: 80rpx;
  219. color: #333333;
  220. font-size: 32rpx;
  221. line-height: 80rpx;
  222. font-weight: bold;
  223. display: flex;
  224. justify-content: space-between;
  225. }
  226. .content{
  227. background-color: #FFFFFF;
  228. }
  229. .btn2{
  230. width: 200rpx;
  231. height: 64rpx;
  232. background: linear-gradient(0deg, #FFB102, #FD644F);
  233. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  234. border-radius: 32rpx;
  235. line-height: 64rpx;
  236. text-align: center;
  237. }
  238. .btn1{
  239. width: 200rpx;
  240. height: 64rpx;
  241. background: linear-gradient(0deg, #015EEA, #00C0FA);
  242. border-radius: 32rpx;
  243. line-height: 64rpx;
  244. text-align: center;
  245. margin-right: 20rpx;
  246. }
  247. .bottomBox{
  248. position: fixed;
  249. bottom: 0;
  250. width: 100%;
  251. left: 0;
  252. height:98rpx ;
  253. background-color: #FFFFFF;
  254. display: flex;
  255. justify-content: space-between;
  256. align-items: center;
  257. padding: 0 30rpx;
  258. }
  259. .blackFont{
  260. color: #333333;
  261. margin: 0 4rpx;
  262. }
  263. .wk_icon{
  264. width: 24rpx;
  265. height: 24rpx;
  266. margin-right: 12rpx;
  267. }
  268. .noteTag{
  269. ont-size: 24rpx;
  270. font-family: PingFang SC;
  271. font-weight: 500;
  272. color: #999999;
  273. align-items: center;
  274. }
  275. .priceTag{
  276. font-size: 30rpx;
  277. font-family: PingFang SC;
  278. font-weight: bold;
  279. color: #FF2D55;
  280. }
  281. .titleTag{
  282. font-size: 32rpx;
  283. font-weight: bold;
  284. color: #333333;
  285. margin-left: 8rpx;
  286. }
  287. .yearTag{
  288. width: 80rpx;
  289. height: 32rpx;
  290. background: #EBF5FF;
  291. border: 2rpx solid #007AFF;
  292. border-radius: 16rpx;
  293. font-size: 24rpx;
  294. color: #007AFF;
  295. text-align: center;
  296. line-height: 32rpx;
  297. }
  298. .itemBox{
  299. background: #FFFFFF;
  300. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  301. border-radius: 24rpx;
  302. width: 100%;
  303. padding: 20rpx;
  304. margin-bottom: 20rpx;
  305. }
  306. </style>