detail.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view>
  3. <view style="background-color: #FFFFFF;">
  4. <view >
  5. <image :src="$method.splitImgHost(detail.coverUrl)" style="height: 461rpx;width: 100%;"></image>
  6. <view style="padding:20rpx">
  7. <view style="display: flex;margin-top: 13rpx;">
  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>
  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. <u-line color="#D6D6DB" />
  22. </view>
  23. <view style="padding: 20rpx;" v-show="current==0">
  24. <view class="content">
  25. <view v-html="detail.mobileDetailHtml"></view>
  26. </view>
  27. </view>
  28. <view style="padding: 20rpx;" v-show="current==1">
  29. <view >
  30. <view v-for="(item,index) in courseList" >
  31. <view class="courseItem" @click="openCourse(item)">
  32. <view>{{item.courseName}}</view>
  33. <view>
  34. <u-icon name="arrow-down" v-if="item.down"></u-icon>
  35. <u-icon name="arrow-up" v-if="!item.down"></u-icon>
  36. </view>
  37. </view>
  38. <view v-if="item.down">
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="bottomBox">
  44. <view class="priceTag">¥ {{detail.standPrice}}</view>
  45. <view style="display: flex;color: #FFFFFF;align-items: center;">
  46. <view class="btn1" @click="addCart">加购物车</view>
  47. <view class="btn2" @click="buy">立即购买</view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import { mapGetters } from 'vuex';
  54. export default {
  55. data() {
  56. return {
  57. id:0,
  58. list: [
  59. {
  60. name: '详情'
  61. },
  62. {
  63. name: '大纲'
  64. }
  65. ],
  66. current:0,
  67. detail:{},
  68. courseList:[]
  69. };
  70. },
  71. onUnload() {
  72. },
  73. computed: { ...mapGetters(['userInfo']) },
  74. onLoad(option) {
  75. this.id = option.id;
  76. this.getDetail()
  77. this.goodsCourseList()
  78. },
  79. onShow() {
  80. },
  81. methods: {
  82. openCourse(item){
  83. item.down = !item.down
  84. if(!item.down){
  85. this.menuList(item.courseId)
  86. }
  87. },
  88. addShopCart() {
  89. let self = this
  90. this.$api.addCart({goodsId:this.id}).then(res => {
  91. if(res.data.code==200){
  92. uni.setStorageSync('updateCart',1) //提醒刷新购物车
  93. uni.showToast({
  94. title: '添加成功'
  95. });
  96. }else{
  97. this.$u.toast(res.data.msg);
  98. }
  99. });
  100. },
  101. goodsCourseList() {
  102. let self = this
  103. this.$api.goodsCourseList(this.id).then(res => {
  104. if(res.data.code==200){
  105. for(let i=0;i<res.data.rows.length;i++){
  106. let item = res.data.rows[i]
  107. item.down = true
  108. }
  109. self.courseList = res.data.rows
  110. }
  111. });
  112. },
  113. menuList(courseId) {
  114. let self = this
  115. this.$api.menuList({courseId:courseId}).then(res => {
  116. if(res.data.code==200){
  117. console.log(res.data)
  118. }
  119. });
  120. },
  121. getDetail() {
  122. let self = this
  123. this.$api.goodsDetail(this.id).then(res => {
  124. if(res.data.code==200){
  125. self.detail = res.data.data
  126. console.log(self.detail.mobileDetailHtml)
  127. }
  128. });
  129. },
  130. buy(){
  131. if(this.$method.isGoLogin()){
  132. return
  133. }
  134. this.$navTo.togo('/pages2/order/confirm_list');
  135. },
  136. addCart(){
  137. if(this.$method.isGoLogin()){
  138. return
  139. }
  140. this.addShopCart()
  141. },
  142. open(item){
  143. item.showChildren = !item.showChildren
  144. },
  145. change(index){
  146. this.current = index;
  147. }
  148. }
  149. };
  150. </script>
  151. <style >
  152. page{
  153. background-color: #EAEEF1;
  154. }
  155. </style>
  156. <style scope>
  157. .contentBox{
  158. }
  159. .courseItem{
  160. width: 100%;
  161. height: 80rpx;
  162. background: #FFFFFF;
  163. border-radius: 16rpx;
  164. color: #333333;
  165. font-size: 32rpx;
  166. line-height: 80rpx;
  167. font-weight: bold;
  168. padding: 0 10rpx;
  169. display: flex;
  170. justify-content: space-between;
  171. }
  172. .content{
  173. background-color: #FFFFFF;
  174. }
  175. .btn2{
  176. width: 200rpx;
  177. height: 64rpx;
  178. background: linear-gradient(0deg, #FFB102, #FD644F);
  179. box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
  180. border-radius: 32rpx;
  181. line-height: 64rpx;
  182. text-align: center;
  183. }
  184. .btn1{
  185. width: 200rpx;
  186. height: 64rpx;
  187. background: linear-gradient(0deg, #015EEA, #00C0FA);
  188. border-radius: 32rpx;
  189. line-height: 64rpx;
  190. text-align: center;
  191. margin-right: 20rpx;
  192. }
  193. .bottomBox{
  194. position: fixed;
  195. bottom: 0;
  196. width: 100%;
  197. left: 0;
  198. height:98rpx ;
  199. background-color: #FFFFFF;
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. padding: 0 30rpx;
  204. }
  205. .blackFont{
  206. color: #333333;
  207. margin: 0 4rpx;
  208. }
  209. .wk_icon{
  210. width: 24rpx;
  211. height: 24rpx;
  212. margin-right: 12rpx;
  213. }
  214. .noteTag{
  215. ont-size: 24rpx;
  216. font-family: PingFang SC;
  217. font-weight: 500;
  218. color: #999999;
  219. align-items: center;
  220. }
  221. .priceTag{
  222. font-size: 30rpx;
  223. font-family: PingFang SC;
  224. font-weight: bold;
  225. color: #FF2D55;
  226. }
  227. .titleTag{
  228. font-size: 32rpx;
  229. font-weight: bold;
  230. color: #333333;
  231. margin-left: 8rpx;
  232. }
  233. .yearTag{
  234. width: 80rpx;
  235. height: 32rpx;
  236. background: #EBF5FF;
  237. border: 2rpx solid #007AFF;
  238. border-radius: 16rpx;
  239. font-size: 24rpx;
  240. color: #007AFF;
  241. text-align: center;
  242. line-height: 32rpx;
  243. }
  244. .itemBox{
  245. background: #FFFFFF;
  246. box-shadow: 0rpx 10rpx 9rpx 1rpx rgba(165, 196, 239, 0.1);
  247. border-radius: 24rpx;
  248. width: 100%;
  249. padding: 20rpx;
  250. margin-bottom: 20rpx;
  251. }
  252. </style>