yingyuNew.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view class="ezy-study-page ezy-cjdc-study-page">
  3. <view class="study-school-year" @click="clickGradeTerm">{{gradeTerm}}</view>
  4. <view class="ezy-study-wrap" @touchstart="onTouchStart" @touchend="onTouchEnd">
  5. <img class="study-name-img" :src="growthImg" />
  6. <!-- <img class="study-book-img" :src="bookImg"/> -->
  7. <view class="study-book-img" @click="handleCheckCatalogue">
  8. <view class="chapter-title-box">{{zhangName}}</view>
  9. </view>
  10. <!-- 动物类型 -->
  11. <view v-if="growthType!=null" :class="currentGrowth()"></view>
  12. <view>
  13. <!-- 小岛 -->
  14. <view class="brand-item" v-for="(item, index) in options.jieList" :key="item.jieId"
  15. @click="listClick(item, index,options)" :class="getClass(options,index,isVip,item)">
  16. <view v-if="isVip === 'VIP'">
  17. <!-- 序号 -->
  18. <!-- <view class="brand-icon">{{ item.number }}</view> -->
  19. <!-- 星星 -->
  20. <view class="brand-finish-icon" v-if="item.studyFlag===1"></view>
  21. <!-- 箭头 -->
  22. <view class="brand-arrow" v-if="animalNum == index"></view>
  23. <!-- 节名称 -->
  24. <view class="brand-content">
  25. <view class="content-text">{{ item.jieName }}</view>
  26. </view>
  27. </view>
  28. <view v-if="isVip == 'Not-Vip'">
  29. <!-- 序号 -->
  30. <!-- <view class="brand-icon">{{ item.number }}</view> -->
  31. <!-- 星星 -->
  32. <view class="brand-finish-icon" v-if="item.studyFlag===1"></view>
  33. <view v-if="item.number !=1" class="brand-lock"></view>
  34. <!-- 箭头 -->
  35. <view v-if="animalNum == index && isVip != 'Visitor'" class="brand-arrow"></view>
  36. <!-- 节名称 -->
  37. <view class="brand-content">
  38. <view class="content-text">{{ item.jieName }}</view>
  39. </view>
  40. </view>
  41. <view v-if="isVip == 'Visitor' && appleTishen =='true'&&item.type!=2 ">
  42. <!-- 锁 -->
  43. <!-- <view class="brand-icon">{{ item.number }} </view> -->
  44. <!-- 锁 -->
  45. <!-- 节名称 -->
  46. <view class="brand-content">
  47. <view class="content-text">{{ item.jieName }} </view>
  48. </view>
  49. </view>
  50. <view v-if="isVip == 'Visitor'&& appleTishen =='false'">
  51. <!-- 锁 -->
  52. <!-- <view class="brand-icon">{{ item.number }} </view> -->
  53. <!-- 锁 -->
  54. <view v-if="item.number !=1" class="brand-lock"></view>
  55. <!-- 箭头 -->
  56. <view v-if="animalNum == index && isVip != 'Visitor'" class="brand-arrow"></view>
  57. <!-- 节名称 -->
  58. <view class="brand-content">
  59. <view class="content-text">{{ item.jieName }} </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script setup>
  68. import {
  69. reactive,
  70. ref,
  71. watch,
  72. getCurrentInstance,
  73. nextTick,
  74. onMounted
  75. } from "vue";
  76. import cacheManager from "@/utils/cacheManager.js";
  77. import {
  78. toast,
  79. getUserIdentity
  80. } from "@/utils/common";
  81. import {
  82. onShow
  83. } from '@dcloudio/uni-app';
  84. const growthType = ref(null);
  85. const appleTishen = ref(null);
  86. const growthImg = ref(null);
  87. const bookImg = ref(null);
  88. const youkeImageBook = ref(null);
  89. const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue', 'listClick'])
  90. const props = defineProps({
  91. options: {
  92. type: Object,
  93. },
  94. youkeImage: {
  95. String: '',
  96. },
  97. youkeImageBook: {
  98. String: '',
  99. },
  100. gradeTerm: {
  101. type: String,
  102. },
  103. weizhiIndex: {
  104. type: String,
  105. },
  106. zhangName: {
  107. type: String,
  108. },
  109. currentSwiperIndex: {
  110. type: Number,
  111. default: 0
  112. }
  113. })
  114. onShow(() => {
  115. growthType.value = cacheManager.get('auth') ? cacheManager.get('auth').growthType : props.youkeImage
  116. growthImg.value = cacheManager.get('auth') ? cacheManager.get('zhangInfo').icon : props.youkeImage;
  117. // 待修改 wgy看这
  118. bookImg.value = cacheManager.get('auth') ? cacheManager.get('zhangInfo').icon : props.youkeImage;
  119. youkeImageBook.value = cacheManager.get('auth') ? cacheManager.get('zhangInfo').zhangIcon : props
  120. .youkeImageBook;
  121. appleTishen.value = cacheManager.get('youkeTishen').toString()
  122. console.log(appleTishen.value);
  123. })
  124. const isVip = getUserIdentity();
  125. console.log('isVip', isVip);
  126. const gradeMapping = {
  127. 1: '一年级',
  128. 2: '二年级',
  129. 3: '三年级',
  130. 4: '四年级',
  131. 5: '五年级',
  132. 6: '六年级'
  133. };
  134. const termMapping = {
  135. 1: ' 数学',
  136. 2: ' 英语'
  137. };
  138. let startX = ref(0);
  139. let isSliding = ref(false);
  140. let endX = ref(0);
  141. let gradeTerm = ref('');
  142. let animalNum = ref(0);
  143. function clickGradeTerm() {
  144. $emit('clickGradeTerm');
  145. }
  146. function aaa() {
  147. console.log('123123123');
  148. }
  149. function listClick(data, index, data2) {
  150. nextTick(() => {
  151. animalNum.value = index
  152. })
  153. cacheManager.updateObject('zhangInfo', {
  154. weizhiIndex: index
  155. })
  156. setTimeout(() => {
  157. $emit('listClick', data, data2, index);
  158. }, 300)
  159. }
  160. function currentGrowth(data) {
  161. if (growthType.value == 0) {
  162. return 'animal-img dan-img'
  163. } else if (growthType.value == 1) {
  164. return 'animal-img xiao-e-img'
  165. } else if (growthType.value == 2) {
  166. return 'animal-img zhong-e-img'
  167. } else {
  168. return 'animal-img da-e-img'
  169. }
  170. }
  171. // 获取节class
  172. function getClass(data, index, isVip, item) {
  173. let brandActive = '';
  174. if (isVip === 'VIP') {
  175. brandActive = 'brand-active';
  176. } else if (item.firstFlag == 1 && isVip == 'Not-Vip') {
  177. brandActive = 'brand-active';
  178. } else if (appleTishen.value == 'true' && isVip == 'Visitor') {
  179. brandActive = 'brand-active';
  180. } else if (item.firstFlag == 1 && isVip == 'Visitor' && item.type == 1) {
  181. brandActive = 'brand-active';
  182. } else {
  183. brandActive = '';
  184. }
  185. let indexLast = data.jieList.length - 1;
  186. if (appleTishen.value == 'true' && isVip == 'Visitor') {
  187. // 判断最后一个为名称是否为单元测试,是单元测试则返回ceshi-jie
  188. if (index === indexLast && data.jieList[data.jieList.length - 1].jieName == 'Testing') {
  189. return ''
  190. } else {
  191. return brandActive;
  192. }
  193. } else {
  194. // 判断最后一个为名称是否为单元测试,是单元测试则返回ceshi-jie
  195. if (index === indexLast && data.jieList[data.jieList.length - 1].jieName == 'Testing') {
  196. return 'ceshi-brand-item' + ' ' + brandActive;
  197. } else {
  198. return brandActive;
  199. }
  200. }
  201. }
  202. function handleCheckCatalogue() {
  203. if (appleTishen.value == 'true' && isVip == 'Visitor') {
  204. return false
  205. }
  206. $emit('handleCheckCatalogue');
  207. }
  208. function onTouchStart(event) {
  209. // console.log(event.touches.length);
  210. isSliding.value = false
  211. if (event.touches.length === 1) {
  212. isSliding.value = true;
  213. startX.value = event.touches[0].pageX;
  214. } else {
  215. isSliding.value = false;
  216. event.preventDefault()
  217. return
  218. }
  219. }
  220. function onSwipeLeft(event) {
  221. // console.log('11111');
  222. if (cacheManager.get('auth')) {
  223. $emit('onLeft');
  224. }
  225. }
  226. function onSwipeRight(event) {
  227. //console.log('22222');
  228. if (cacheManager.get('auth')) {
  229. $emit('onRight');
  230. }
  231. }
  232. function onTouchEnd(event) {
  233. if (isSliding.value) {
  234. const distanceX = event.changedTouches[0].clientX - startX.value
  235. if (distanceX > 0) {
  236. onSwipeLeft();
  237. } else if (distanceX < 0) {
  238. onSwipeRight();
  239. }
  240. isSliding.value = false
  241. } else {
  242. console.log('error');
  243. }
  244. }
  245. function dataRecom(data) {
  246. // const index = data.jieList.findIndex(item => item.studyFlag == 0);
  247. // if (index !== -1) {
  248. // data.jieList[index].daeFlag = true;
  249. // animalNum.value = index
  250. // }
  251. animalNum.value = cacheManager.get("zhangInfo").weizhiIndex || 0
  252. }
  253. watch(() => props.options, (newVal, oldVal) => {
  254. // console.log('New options:', newVal);
  255. // console.log('Old options:', oldVal);
  256. // 在这里可以根据新的 options 做一些操作,比如发起请求等
  257. dataRecom(newVal)
  258. }, {
  259. deep: true,
  260. immediate: true
  261. });
  262. watch(
  263. () => props.currentSwiperIndex,
  264. (newVal, oldVal) => {
  265. console.log('swiper 索引变化:', newVal)
  266. animalNum.value =0
  267. // 执行你的方法
  268. //yourMethodName(newVal)
  269. }
  270. )
  271. watch(() => props.gradeTerm, (newVal, oldVal) => {
  272. // console.log('New options:', newVal);
  273. // console.log('Old options:', oldVal);
  274. // 在这里可以根据新的 options 做一些操作,比如发起请求等
  275. gradeTerm.value = newVal
  276. }, {
  277. deep: true,
  278. immediate: true
  279. });
  280. </script>
  281. <style>
  282. </style>