index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <view class="content">
  3. <statusBar :item="navBarData"></statusBar>
  4. <!-- 消息提示 -->
  5. <msgPop></msgPop>
  6. <view class="top">
  7. <image :src="adv.img" mode="aspectFill"
  8. @click="gotoHome">
  9. </image>
  10. </view>
  11. <view class="sortBlock">
  12. <!-- <view class="sortCostcon" @click="gotoCost">
  13. <view class="sortCostcontent">
  14. <view class="costTit">
  15. 收费专区
  16. </view>
  17. <view class="costbri">
  18. <text class="di">暂未开放</text>
  19. </view>
  20. </view>
  21. <view class="costimgblc">
  22. <image src="../../static/Framezzz.png" class="costImg" mode="aspectFill"></image>
  23. </view>
  24. </view> -->
  25. <view class="sortleft">
  26. <view :class="item.cla" v-for="(item,index) in sortList" @click="gotoTab" :data-index="item">
  27. <!-- <image class="sortImg" src="../../static/Rectangle 937.png" mode="aspectFill"></image> -->
  28. <view class="sortcontent">
  29. <view class="contentl">
  30. <view class="tit">
  31. {{item.tit}}
  32. </view>
  33. <view class="bri">
  34. <text :class="item.briCla">{{item.bri}}</text>
  35. </view>
  36. </view>
  37. <view class="sortleftImgBlock">
  38. <image class="sortleftImg" :src="item.img" mode="aspectFill"></image>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <viewX-Case>
  45. <template #title>
  46. <view class="title three-font">推荐内容</view>
  47. </template>
  48. <template #lookMore>
  49. <view class="lookMore fz-font" @click="listBlock1More">查看更多</view>
  50. </template>
  51. <template #teaching>
  52. <!-- 推荐课程组件 -->
  53. <listBlock1 ref="listBlock1" :classList="classList"></listBlock1>
  54. </template>
  55. </viewX-Case>
  56. <view class="" style="height: 30rpx; width: 100%"> </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. title: "Hello",
  64. navBarData: {
  65. title: "首页", //导航栏标题
  66. btn: 0, //是否显示返回按钮 0不显示 1 显示
  67. },
  68. isRote: false,
  69. animation: null,
  70. animationData: {},
  71. adv: {},
  72. // 推荐课程
  73. classList: [],
  74. sortList: [{
  75. tit: '活动专区',
  76. bri: '精彩纷呈',
  77. img: '../../static/Framehhh.png',
  78. cla: 'sortcon',
  79. briCla: 'di'
  80. },
  81. {
  82. tit: '课程专区',
  83. bri: '海量资源',
  84. img: '../../static/Framesss.png',
  85. cla: 'sortcon sortcon2',
  86. briCla: 'di2'
  87. }
  88. ]
  89. };
  90. },
  91. onShareTimeline() {
  92. uni.share({
  93. provider: "weixin",
  94. scene: "WXSceneTimeline",
  95. type: 0,
  96. href: "http://uniapp.dcloud.io/",
  97. title: "uni-app分享",
  98. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  99. imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
  100. success: function(res) {
  101. console.log("success:" + JSON.stringify(res));
  102. },
  103. fail: function(err) {
  104. console.log("fail:" + JSON.stringify(err));
  105. }
  106. });
  107. },
  108. // 分享
  109. onShareAppMessage() {
  110. uni.share({
  111. provider: "weixin",
  112. scene: "WXSceneSession",
  113. type: 1,
  114. summary: "我正在使用丽湖双创小程序,赶紧跟我一起来体验!",
  115. success: function(res) {
  116. console.log("success:" + JSON.stringify(res));
  117. },
  118. fail: function(err) {
  119. console.log("fail:" + JSON.stringify(err));
  120. }
  121. });
  122. },
  123. methods: {
  124. gotoTab(e) {
  125. // console.log(e.currentTarget.dataset.index.tit);
  126. let aaa = e.currentTarget.dataset.index.tit
  127. if (aaa == '活动专区') {
  128. return uni.switchTab({
  129. url: '/pages/activityPageNew/activityPageNew'
  130. })
  131. } else {
  132. uni.switchTab({
  133. url: '/pages/resource/resource'
  134. })
  135. }
  136. },
  137. gotoCost() {
  138. uni.showToast({
  139. title: '功能暂未开放,敬请期待',
  140. icon: 'none'
  141. })
  142. },
  143. // 获取教研室活动list 数据
  144. getlistBlock1Data() {
  145. let data = {
  146. openid: uni.getStorageSync('oId'),
  147. ty: 3,
  148. page: 1, //下拉获取更多的备用字段
  149. lim: 12 //一次获取多少数据
  150. }
  151. this.$request('/selectActivity', "POST", data).then(res => {
  152. // console.log('推荐活动', res[0]);
  153. this.classList = res[0]
  154. // console.log('推荐课程',this.classList);
  155. })
  156. },
  157. // 跳转到推荐课程查看更多
  158. listBlock1More() {
  159. const value = this.$store.state.user.openid;
  160. if (value == '') return this.goLog()
  161. uni.navigateTo({
  162. url: "/pages/teachingList/teachingList",
  163. });
  164. },
  165. // 顶部大图跳转外部链接
  166. gotoHome() {
  167. // console.log(this.adv);
  168. // const web = this.classList[this.current];
  169. const url = this.adv.href
  170. uni.navigateTo({
  171. url: "/pages/skipone/skipone?item="+encodeURIComponent(JSON.stringify(url))
  172. // url: "/pages/skipone/skipone?url=" + encodeURIComponent(JSON.stringify(url)),
  173. });
  174. },
  175. goLog() {
  176. uni.navigateTo({
  177. url: "/pages/login_Wechat/login_Wechat",
  178. });
  179. },
  180. // 获取顶部大图
  181. getAdv() {
  182. this.$request('/selectAdvertisement', "get", {
  183. typ: 0
  184. }).then(res => {
  185. // console.log(res);
  186. this.adv=res[0][0]
  187. })
  188. }
  189. },
  190. onLoad() {
  191. // this.animation = uni.createAnimation()
  192. this.getAdv()
  193. },
  194. onShow() {
  195. // 清空推荐课程
  196. // this.classList = []
  197. // console.log(this.$store.state.msgpop);
  198. // 获取数据
  199. this.getlistBlock1Data()
  200. this.getAllMessage() // 调用app.js中的方法
  201. // // 因为组件没有onshow
  202. // // 获取收藏事件
  203. this.$refs.listBlock1.getdata()
  204. }
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. .content {
  209. // 分类区样式
  210. .sortBlock {
  211. width: 750rpx;
  212. margin: 20rpx 0;
  213. background-color: rgba(255, 255, 255, 1);
  214. display: flex;
  215. justify-content: space-between;
  216. padding: 30rpx;
  217. position: relative;
  218. // 收费区
  219. .sortCostcon {
  220. padding: 30rpx;
  221. width: 336rpx;
  222. height: 300rpx;
  223. flex-shrink: 0;
  224. background-image: url('../../static/Rectangle1922.png');
  225. background-repeat: no-repeat;
  226. background-size: 100%;
  227. .sortCostcontent {
  228. display: flex;
  229. flex-direction: column;
  230. .costTit {
  231. font-weight: 400rpx;
  232. font-size: 36rpx;
  233. height: 48rpx;
  234. line-height: 48rpx;
  235. }
  236. .costbri {
  237. color: rgba(244, 142, 143, 1);
  238. font-size: 24rpx;
  239. width: 400;
  240. margin: 10rpx 0;
  241. }
  242. }
  243. .costimgblc {
  244. display: flex;
  245. justify-content: flex-end;
  246. .costImg {
  247. width: 162rpx;
  248. height: 162rpx;
  249. }
  250. }
  251. }
  252. .sortleft {
  253. flex: 1;
  254. display: flex;
  255. // flex-direction: column;
  256. justify-content: space-between;
  257. // margin-left: 20rpx;
  258. .sortcon2 {
  259. background-image: url('https://teacherapi.cocorobo.cn/teaching-file/static/Rectangle938.png') !important;
  260. }
  261. .sortcon {
  262. width: 336rpx;
  263. height: 140rpx;
  264. background-image: url('https://teacherapi.cocorobo.cn/teaching-file/static/Rectangle937.png');
  265. background-repeat: no-repeat;
  266. background-size: 100%;
  267. display: flex;
  268. padding: 20rpx;
  269. .sortImg {
  270. position: absolute;
  271. left: 0;
  272. top: 0;
  273. width: 100%;
  274. height: 100%;
  275. }
  276. .sortcontent {
  277. display: flex;
  278. width: 100%;
  279. height: 100%;
  280. color: #000;
  281. .contentl {
  282. width: 70%;
  283. .tit {
  284. font-size: 36rpx;
  285. line-height: 48rpx;
  286. }
  287. .bri {
  288. font-size: 24rpx;
  289. height: 48rpx;
  290. width: 144rpx;
  291. line-height: 32rpx;
  292. position: relative;
  293. .di {
  294. position: absolute;
  295. bottom: 0;
  296. left: 0;
  297. color: rgba(243, 189, 91, 1);
  298. }
  299. .di2 {
  300. position: absolute;
  301. bottom: 0;
  302. left: 0;
  303. color: rgba(180, 193, 250, 1);
  304. }
  305. }
  306. }
  307. .sortleftImgBlock {
  308. position: relative;
  309. .sortleftImg {
  310. position: absolute;
  311. bottom: -10rpx;
  312. left: 0;
  313. height: 68rpx;
  314. width: 68rpx;
  315. }
  316. }
  317. }
  318. }
  319. }
  320. }
  321. // 顶部大图
  322. .top {
  323. width: 750rpx;
  324. height: 288rpx;
  325. display: flex;
  326. margin-bottom: 20rpx;
  327. align-items: center;
  328. background-color: #fff;
  329. justify-content: center;
  330. image {
  331. height: 246rpx;
  332. width: 690rpx;
  333. border-radius: 10rpx;
  334. }
  335. }
  336. .title {
  337. font-weight: bold;
  338. }
  339. .lookMore {
  340. color: #666666;
  341. // font-size: 14px;
  342. }
  343. }
  344. </style>