yingyongshezhi.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="ezy-my-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">应用设置</text>
  6. </view>
  7. <view class="my-list-box">
  8. <view class="list-row" @click="headClick">
  9. <icon class="list-icon tel-icon"></icon>
  10. <text>头像</text>
  11. <icon style="width: 20px;height: 20px;" class="head-img-box" :style="{backgroundImage: 'url(' + myInfoData.icon + ')'}"></icon>
  12. </view>
  13. <view class="list-row" @click="nichengClick">
  14. <icon class="list-icon tel-icon"></icon>
  15. <text>昵称</text>
  16. <text>{{myInfoData.nickName}}</text>
  17. </view>
  18. <view class="list-row" @click="telClick">
  19. <icon class="list-icon tel-icon"></icon>
  20. <text>手机号码</text>
  21. </view>
  22. <view class="list-row" @click="aboutClick">
  23. <icon class="list-icon about-icon"></icon>
  24. <text>关于我们</text>
  25. </view>
  26. <view v-if="loginFlag" class="list-row" @click="yonghuzhuxiao">
  27. <icon class="list-icon zhuxiao-icon"></icon>
  28. <text>用户注销</text>
  29. </view>
  30. <view v-if="loginFlag" class="list-row" @click="yinsizhengce">
  31. <icon class="list-icon yszc-icon"></icon>
  32. <text>隐私政策</text>
  33. </view>
  34. <view class="list-row" @click="kefudianhua">
  35. <icon class="list-icon kfdh-icon"></icon>
  36. <text>客服与投诉</text>
  37. <text>4001750778</text>
  38. </view>
  39. <view class="list-row" @click="exitLogin">
  40. <icon class="list-icon login-out-icon"></icon>
  41. <text>退出登录</text>
  42. </view>
  43. </view>
  44. <CustomTabBar :levelId="levelId" :currentTabNumber="3" :typeId="typeId" :subjectId="subjectId"
  45. :tipFlag="tipFlag">
  46. </CustomTabBar>
  47. <tip-small-dialog ref="exitDialogRef" @confirm-btn="exitBtn" :content="tipContent"></tip-small-dialog>
  48. <tip-small-dialog ref="zhuxiaoDialogRef" @confirm-btn="zhuxiaoBtn" :content="zhuxiaoContent"></tip-small-dialog>
  49. <duihuanmaDialog ref="duihuanmaDialogRef" @confirm-btn="duihuanmaBtn" title="兑换"></duihuanmaDialog>
  50. <tel-dialog @telClose="telClose" @bindBtn="bindBtn" v-if="telDialogFlag"></tel-dialog>
  51. <agree-content-dialog ref="agreeContentDialogRef" :agreeType="agreeType"></agree-content-dialog>
  52. <tip-small-dialog ref="kefuDialogRef" :title="kefuTitle" @confirm-btn="kefuBtn" :content="kefuContent"
  53. class="kefu-dialog"></tip-small-dialog>
  54. <nichengDialog ref="nichengDialogRef" @confirm-btn="nichengBtn" title="修改昵称"></nichengDialog>
  55. </view>
  56. </template>
  57. <script setup>
  58. import agreeContentDialog from '@/pages/login/agreeContentDialog.vue';
  59. import {
  60. toast,
  61. getUserIdentity
  62. } from "@/utils/common";
  63. import cacheManager from '@/utils/cacheManager.js';
  64. import {
  65. logout
  66. } from '@/api/login.js'
  67. import {
  68. myInfo,
  69. zhuxiao,
  70. duihuanmaCode,
  71. nichengUpdate,
  72. myCardList,
  73. commonCardList
  74. } from '@/api/my.js'
  75. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  76. import {
  77. onLoad
  78. } from '@dcloudio/uni-app';
  79. import {
  80. reactive,
  81. ref
  82. } from "vue";
  83. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue';
  84. import duihuanmaDialog from '@/components/dialog/duihuanmaDialog.vue';
  85. import nichengDialog from '@/components/dialog/nichengDialog.vue';
  86. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  87. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  88. import telDialog from './telDialog.vue'
  89. import {
  90. onShow
  91. } from '@dcloudio/uni-app';
  92. const agreeType = ref(null);
  93. const agreeContentDialogRef = ref(null);
  94. const tipContent = '你确定要执行这个操作吗?';
  95. const zhuxiaoContent = '你确定要执行这个操作吗?';
  96. let loginFlag = ref(false);
  97. let telDialogFlag = ref(false);
  98. let myInfoData = reactive({
  99. userImg: '',
  100. userName: '',
  101. credit: '',
  102. vipFlag: '',
  103. nickName: '',
  104. icon: '',
  105. });
  106. let routerOpt = ref(false);
  107. let appleCode = ref(null);
  108. let currentPlatform = ref(null);
  109. const exitDialogRef = ref(null);
  110. const zhuxiaoDialogRef = ref(null);
  111. const nichengDialogRef = ref(null);
  112. const kefuDialogRef = ref(null);
  113. const kefuTitle = '提示';
  114. const kefuContent = '客服电话:17304117625';
  115. const exitLogin = () => {
  116. exitDialogRef.value.handleShow();
  117. }
  118. function handleBack() {
  119. uni.redirectTo({
  120. url: '/pages/my/index'
  121. })
  122. }
  123. function headClick() {
  124. uni.redirectTo({
  125. url: '/pages/my/headImg'
  126. })
  127. }
  128. function nichengClick() {
  129. nichengDialogRef.value.handleShow();
  130. }
  131. // 退出按钮
  132. const exitBtn = () => {
  133. if (loginFlag.value) {
  134. logout().then(res => {
  135. toast('退出登录成功')
  136. cacheManager.clearAll();
  137. uni.reLaunch({
  138. url: '/pages/login/index'
  139. });
  140. }).catch(err => {
  141. toast('退出登录失败,请稍后重试')
  142. })
  143. } else {
  144. uni.reLaunch({
  145. url: '/pages/login/index'
  146. });
  147. }
  148. }
  149. const zhuxiaoBtn = () => {
  150. let req = {
  151. }
  152. zhuxiao().then(res => {
  153. cacheManager.clearAll();
  154. toast('用户注销成功')
  155. uni.redirectTo({
  156. url: '/pages/login/index'
  157. });
  158. }).catch(err => {
  159. toast('失败,请稍后重试')
  160. })
  161. }
  162. function yonghuzhuxiao() {
  163. zhuxiaoDialogRef.value.handleShow();
  164. }
  165. function nichengBtn(data) {
  166. console.log('data', data);
  167. let req = {
  168. nickName: data
  169. }
  170. nichengUpdate(req).then(res => {
  171. if (res.code == 0) {
  172. toast('修改成功')
  173. myInfoData.nickName = data
  174. } else {
  175. toast('修改失败请重试或联系管理员')
  176. return false
  177. }
  178. }).catch(err => {
  179. })
  180. }
  181. function yinsizhengce() {
  182. agreeType.value = 'ystk'
  183. agreeContentDialogRef.value.handleShow();
  184. }
  185. function kefudianhua() {
  186. kefuDialogRef.value.handleShow();
  187. }
  188. function kefuBtn() {
  189. kefuDialogRef.value.handleClose();
  190. }
  191. // 手机号码
  192. function telClick() {
  193. if (loginFlag.value) {
  194. telDialogFlag.value = true;
  195. } else {
  196. youkeDialogRef.value.handleShow();
  197. }
  198. }
  199. // 手机号码绑定
  200. function bindBtn() {
  201. telDialogFlag.value = false;
  202. myGetAuth()
  203. }
  204. // 关闭手机号码弹窗
  205. function telClose() {
  206. telDialogFlag.value = false;
  207. }
  208. // 关于我们
  209. function aboutClick() {
  210. if (loginFlag.value) {
  211. uni.redirectTo({
  212. url: '/pages/my/aboutPage'
  213. });
  214. } else {
  215. uni.redirectTo({
  216. url: `/pages/my/aboutPage?levelId=${routerOpt.levelId}&typeId=${routerOpt.typeId}&subjectId=${routerOpt.subjectId}&tipFlag=${routerOpt.tipFlag}`
  217. });
  218. }
  219. }
  220. // 获取用户数据
  221. function getMyInfo() {
  222. myInfo({}).then(res => {
  223. myInfoData.userName = res.data.userName;
  224. myInfoData.credit = res.data.credit;
  225. myInfoData.nickName = res.data.nickName;
  226. if (res.data.nickName) {
  227. myInfoData.nickName = res.data.nickName;
  228. } else {
  229. myInfoData.nickName = '鹅状元';
  230. }
  231. if (res.data.icon) {
  232. myInfoData.icon = res.data.icon;
  233. } else {
  234. getUserImg(res.data.growthType)
  235. }
  236. })
  237. }
  238. function getUserImg(data) {
  239. switch (data) {
  240. case 0:
  241. myInfoData.icon = 'static/images/my/head-img0.png'
  242. break;
  243. case 1:
  244. myInfoData.icon = 'static/images/my/head-img1.png'
  245. break;
  246. case 2:
  247. myInfoData.icon = 'static/images/my/head-img2.png'
  248. break;
  249. case 3:
  250. myInfoData.icon = 'static/images/my/head-img3.png'
  251. break;
  252. default:
  253. myInfoData.icon = 'static/images/my/head-unlogin-img.png'
  254. break;
  255. }
  256. }
  257. function isIOSorAndroid() {
  258. const systemInfo = uni.getSystemInfoSync();
  259. console.log('systemInfo', systemInfo);
  260. if (systemInfo.platform == 'ios') {
  261. return currentPlatform.value = 'ios'
  262. } else {
  263. return currentPlatform.value = 'android'
  264. }
  265. }
  266. onLoad((options) => {
  267. isIOSorAndroid()
  268. loginFlag.value = true;
  269. getMyInfo();
  270. })
  271. </script>