index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="my-head-box">
  4. <icon class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.userImg + ')'}"></icon>
  5. <view class="head-content-box">
  6. <text>{{myInfoData.userName}}</text>
  7. <view class="ezy-jf-box" v-if="loginFlag">
  8. <icon class="jf-icon"></icon>
  9. <text class="jf-text">{{myInfoData.credit}}</text>
  10. </view>
  11. </view>
  12. </view>
  13. <swiper class="my-hyqy-swiper" circular :indicator-dots="hyqyData.indicatorDots" :autoplay="hyqyData.autoplay"
  14. :interval="hyqyData.interval" :duration="hyqyData.duration" indicator-color="#5195d3"
  15. indicator-active-color="#83d9ff" v-if="bannerArr">
  16. <!-- 1.数学 2.英语-->
  17. <swiper-item v-for="(item, index) in bannerArr" :key="index" class="hyqy-box" @click="hyqyBtn(item)">
  18. <img :src="item.addCover" class="hyqy-box-img" />
  19. </swiper-item>
  20. </swiper>
  21. <view class="my-list-box">
  22. <view class="list-row" @click="telClick">
  23. <icon class="list-icon tel-icon"></icon>
  24. <text>手机号码</text>
  25. </view>
  26. <view class="list-row" @click="checkWrong">
  27. <icon class="list-icon error-icon"></icon>
  28. <text>我的错题</text>
  29. </view>
  30. <view v-if="loginFlag" class="list-row" @click="orderClick">
  31. <icon class="list-icon order-icon"></icon>
  32. <text>我的订单</text>
  33. </view>
  34. <view class="list-row" @click="aboutClick">
  35. <icon class="list-icon about-icon"></icon>
  36. <text>关于我们</text>
  37. </view>
  38. <view class="list-row" @click="cpscClick">
  39. <icon class="list-icon cpsc-icon"></icon>
  40. <text>产品商城</text>
  41. </view>
  42. <view v-if="loginFlag" class="list-row" @click="sxtkClick">
  43. <icon class="list-icon sxtk-icon"></icon>
  44. <text>数学题库</text>
  45. </view>
  46. <view v-if="loginFlag" class="list-row" @click="xxjlClick">
  47. <icon class="list-icon sxtk-icon"></icon>
  48. <text>学习记录</text>
  49. </view>
  50. <view v-if="appleCode=='true'&&currentPlatform=='ios'" class="list-row" @click="duihuamaDuihuan">
  51. <icon class="list-icon duihuanma-icon"></icon>
  52. <text>兑换码</text>
  53. </view>
  54. <view v-if="currentPlatform=='android'" class="list-row" @click="duihuamaDuihuan">
  55. <icon class="list-icon duihuanma-icon"></icon>
  56. <text>兑换码</text>
  57. </view>
  58. <view v-if="loginFlag" class="list-row" @click="yonghuzhuxiao">
  59. <icon class="list-icon zhuxiao-icon"></icon>
  60. <text>用户注销</text>
  61. </view>
  62. <view v-if="loginFlag" class="list-row" @click="yinsizhengce">
  63. <icon class="list-icon yszc-icon"></icon>
  64. <text>隐私政策</text>
  65. </view>
  66. <view class="list-row" @click="kefudianhua">
  67. <icon class="list-icon kfdh-icon"></icon>
  68. <text>客服与投诉</text>
  69. </view>
  70. <view class="list-row" @click="exitLogin">
  71. <icon class="list-icon login-out-icon"></icon>
  72. <text>退出登录</text>
  73. </view>
  74. </view>
  75. <CustomTabBar :levelId="levelId" :currentTabNumber="3" :typeId="typeId" :subjectId="subjectId"
  76. :tipFlag="tipFlag">
  77. </CustomTabBar>
  78. <tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
  79. <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
  80. <tip-small-dialog ref="zhuxiaoDialogRef" @confirm-btn="zhuxiaoBtn" :content="zhuxiaoContent"></tip-small-dialog>
  81. <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
  82. <tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
  83. <agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
  84. <tip-small-dialog ref="kefuDialogRef" :title="kefuTitle" @confirm-btn="kefuBtn" :content="kefuContent"
  85. class="kefu-dialog"></tip-small-dialog>
  86. </view>
  87. </template>
  88. <script setup>
  89. import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
  90. import {
  91. toast,
  92. getUserIdentity
  93. } from "@/utils/common";
  94. import cacheManager from '@/utils/cacheManager.js';
  95. import {
  96. logout
  97. } from '@/api/login.js'
  98. import {
  99. myInfo,
  100. zhuxiao,
  101. duihuanmaCode,
  102. myCardList,
  103. commonCardList
  104. } from '@/api/my.js'
  105. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  106. import {
  107. getCurrentInstance
  108. } from 'vue';
  109. import {
  110. onLoad
  111. } from '@dcloudio/uni-app';
  112. import {
  113. reactive,
  114. ref
  115. } from "vue";
  116. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  117. import duihuanmaDialog from '@/components/dialog/duihuanmaDialog.vue';
  118. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  119. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  120. import telDialog from './telDialog.vue'
  121. import {
  122. MESSAGE_VISITER_TO_LOGIN
  123. } from "@/utils/constant.js"
  124. import {
  125. onShow
  126. } from '@dcloudio/uni-app';
  127. onShow(() => {
  128. if (!cacheManager.get('auth')) {
  129. youkeFun();
  130. } else {
  131. // 非游客
  132. noYoukeFun();
  133. }
  134. })
  135. const agreeType = ref(null);
  136. const agreeContentDialogRef = ref(null);
  137. const subjectId = ref(null); //游客使用
  138. const levelId = ref(null); //游客使用
  139. const typeId = ref(null); //游客使用
  140. const tipFlag = ref(null); //游客使用
  141. const tipContent = '你确定要执行这个操作吗?';
  142. const zhuxiaoContent = '你确定要执行这个操作吗?';
  143. const duihuanmaContent = '你确定要执行这个操作吗?';
  144. let hyqyData = reactive({
  145. indicatorDots: true,
  146. autoplay: true,
  147. interval: 10000,
  148. duration: 500
  149. });
  150. let loginFlag = ref(false);
  151. let telDialogFlag = ref(false);
  152. let myInfoData = reactive({
  153. userImg: '',
  154. userName: '',
  155. credit: '',
  156. vipFlag: '',
  157. });
  158. let routerOpt = ref(false);
  159. let appleCode = ref(null);
  160. let currentPlatform = ref(null);
  161. const exitDialogRef = ref(null);
  162. const youkeDialogRef = ref(null);
  163. const zhuxiaoDialogRef = ref(null);
  164. const duihuanmaDialogRef = ref(null);
  165. const bannerArr = ref(null);
  166. const kefuDialogRef = ref(null);
  167. const kefuTitle = '提示';
  168. const kefuContent = '客服电话:17304117625';
  169. const exitLogin = () => {
  170. exitDialogRef.value.handleShow();
  171. }
  172. // 退出按钮
  173. const exitBtn = () => {
  174. if (loginFlag.value) {
  175. logout().then(res => {
  176. toast('退出登录成功')
  177. cacheManager.clearAll();
  178. uni.reLaunch({
  179. url: '/pages/login/index'
  180. });
  181. }).catch(err => {
  182. toast('退出登录失败,请稍后重试')
  183. })
  184. } else {
  185. uni.reLaunch({
  186. url: '/pages/login/index'
  187. });
  188. }
  189. }
  190. const zhuxiaoBtn = () => {
  191. let req = {
  192. }
  193. zhuxiao().then(res => {
  194. cacheManager.clearAll();
  195. toast('用户注销成功')
  196. uni.redirectTo({
  197. url: '/pages/login/index'
  198. });
  199. }).catch(err => {
  200. toast('失败,请稍后重试')
  201. })
  202. }
  203. function yonghuzhuxiao() {
  204. zhuxiaoDialogRef.value.handleShow();
  205. }
  206. function duihuamaDuihuan() {
  207. duihuanmaDialogRef.value.handleShow();
  208. }
  209. function duihuanmaBtn(data) {
  210. console.log('data', data);
  211. let req = {
  212. code: data
  213. }
  214. duihuanmaCode(req).then(res => {
  215. if (res.code == 0) {
  216. toast('兑换成功')
  217. const localList = cacheManager.get('auth').levelIdList || []
  218. const mergeList = [...new Set([...localList, ...res.data.levelIdList])]
  219. cacheManager.updateObject('auth', {
  220. levelIdList: mergeList
  221. })
  222. uni.redirectTo({
  223. url: '/pages/my/index'
  224. })
  225. } else {
  226. toast('兑换失败请重试或联系管理员')
  227. return false
  228. }
  229. }).catch(err => {
  230. })
  231. }
  232. function yinsizhengce() {
  233. agreeType.value = 'ystk'
  234. agreeContentDialogRef.value.handleShow();
  235. }
  236. function kefudianhua() {
  237. kefuDialogRef.value.handleShow();
  238. }
  239. function kefuBtn() {
  240. kefuDialogRef.value.handleClose();
  241. }
  242. // 游客弹窗---确定
  243. function ykConfirm() {
  244. uni.redirectTo({
  245. url: '/pages/login/index'
  246. });
  247. }
  248. // 手机号码
  249. function telClick() {
  250. if (loginFlag.value) {
  251. telDialogFlag.value = true;
  252. } else {
  253. youkeDialogRef.value.handleShow();
  254. }
  255. }
  256. // 手机号码绑定
  257. function bindBtn() {
  258. telDialogFlag.value = false;
  259. myGetAuth()
  260. }
  261. // 关闭手机号码弹窗
  262. function telClose() {
  263. telDialogFlag.value = false;
  264. }
  265. // 关于我们
  266. function aboutClick() {
  267. if (loginFlag.value) {
  268. uni.redirectTo({
  269. url: '/pages/my/aboutPage'
  270. });
  271. } else {
  272. uni.redirectTo({
  273. url: `/pages/my/aboutPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  274. });
  275. }
  276. }
  277. function sxtkClick() {
  278. uni.redirectTo({
  279. url: '/pages/my/sxtkPage'
  280. });
  281. }
  282. function xxjlClick() {
  283. uni.redirectTo({
  284. url: '/pages/my/xuexiJilu'
  285. });
  286. }
  287. // 产品商城
  288. function cpscClick() {
  289. if (loginFlag.value) {
  290. uni.redirectTo({
  291. url: '/pages/mall/mallPage'
  292. });
  293. } else {
  294. uni.redirectTo({
  295. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  296. });
  297. }
  298. }
  299. // 订单
  300. function orderClick() {
  301. if (loginFlag.value) {
  302. uni.redirectTo({
  303. url: '/pages/pay/order'
  304. });
  305. } else {
  306. youkeDialogRef.value.handleShow();
  307. }
  308. }
  309. // 获取用户数据
  310. function getMyInfo() {
  311. myInfo({}).then(res => {
  312. getUserImg(res.data.growthType)
  313. myInfoData.userName = res.data.userName;
  314. myInfoData.credit = res.data.credit;
  315. })
  316. getMyCardList();
  317. }
  318. // 登录人员的cardlist
  319. function getMyCardList() {
  320. myCardList({}).then(res => {
  321. bannerArr.value = res.data;
  322. })
  323. }
  324. // 游客的cardList
  325. function getCommonCardList() {
  326. commonCardList({}).then(res => {
  327. bannerArr.value = res.data;
  328. })
  329. }
  330. // 获取用户头像
  331. function getUserImg(data) {
  332. switch (data) {
  333. case 0:
  334. myInfoData.userImg = 'static/images/my/head-img0.png'
  335. break;
  336. case 1:
  337. myInfoData.userImg = 'static/images/my/head-img1.png'
  338. break;
  339. case 2:
  340. myInfoData.userImg = 'static/images/my/head-img2.png'
  341. break;
  342. case 3:
  343. myInfoData.userImg = 'static/images/my/head-img3.png'
  344. break;
  345. default:
  346. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  347. break;
  348. }
  349. }
  350. // 点击card
  351. function hyqyBtn(data) {
  352. if (loginFlag.value) {
  353. uni.redirectTo({
  354. url: '/pages/mall/mallPage?cardId=' + data.id + '&subjectId=' + data.subjectId + '&from=myPage'
  355. })
  356. } else {
  357. uni.redirectTo({
  358. url: `/pages/mall/mallPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&cardId=${data.id}&subjectId=${data.subjectId}&tipFlag=${routerOpt.tipFlag}`
  359. });
  360. }
  361. }
  362. // 判断是否是游客
  363. function myGetAuth() {
  364. let LocalStorage = cacheManager.get('auth');
  365. if (LocalStorage) {
  366. // 非游客
  367. noYoukeFun()
  368. } else {
  369. youkeFun();
  370. }
  371. }
  372. // 游客
  373. function youkeFun() {
  374. // 获取广告
  375. getCommonCardList();
  376. levelId.value = routerOpt.levelId
  377. typeId.value = routerOpt.typeId
  378. subjectId.value = routerOpt.subjectId
  379. tipFlag.value = routerOpt.tipFlag
  380. // my游客
  381. loginFlag.value = false;
  382. myInfoData.userName = '游客';
  383. myInfoData.userImg = 'static/images/my/head-unlogin-img.png'
  384. }
  385. // 非游客
  386. function noYoukeFun() {
  387. loginFlag.value = true;
  388. getMyInfo();
  389. }
  390. function isIOSorAndroid() {
  391. const systemInfo = uni.getSystemInfoSync();
  392. console.log('systemInfo', systemInfo);
  393. if (systemInfo.platform == 'ios') {
  394. return currentPlatform.value = 'ios'
  395. } else {
  396. return currentPlatform.value = 'android'
  397. }
  398. }
  399. onLoad((options) => {
  400. if (!cacheManager.get('auth')) {
  401. // 游客
  402. routerOpt = options;
  403. } else {
  404. appleCode.value = cacheManager.get("auth").appleCode.toString()
  405. isIOSorAndroid()
  406. }
  407. })
  408. function checkWrong() {
  409. if (loginFlag.value) {
  410. const AuthCode = getUserIdentity();
  411. if (AuthCode == 'Visitor') {
  412. youkeDialogRef.value.handleShow();
  413. return;
  414. }
  415. uni.redirectTo({
  416. url: '/pages/wrong/index'
  417. })
  418. } else {
  419. youkeDialogRef.value.handleShow();
  420. }
  421. }
  422. </script>