index.vue 12 KB

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