setting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="page">
  3. <view class="list_info">
  4. <view class="">
  5. <!-- 基础设置组 -->
  6. <view class="group-header">基础设置</view>
  7. <view class="item basic" v-for="(item, index) in basicSettings" :key="item.name + index"
  8. @click="goPage(item.path)">
  9. <view class="item-left">
  10. <image class="icon" :src="item.icon" mode="widthFix"></image>
  11. <text>{{ item.name }}</text>
  12. </view>
  13. <view class="item-right">
  14. <switch v-if="item.switch == 1" checked class="custom-switch" color="#acf934"
  15. style="transform: scale(0.7)" />
  16. <image v-else class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="">
  21. <!-- 更多设置组 -->
  22. <view class="group-header" style="margin-top: 20rpx">更多</view>
  23. <view class="item more" v-for="(item, index) in moreSettings" :key="index + item.name"
  24. @click="goPage(item.path, item)">
  25. <view class="item-left">
  26. <image class="icon" :src="item.icon" mode="widthFix"></image>
  27. <text>{{ item.name }}</text>
  28. </view>
  29. <view class="item-right">
  30. <switch v-if="item.switch == 1" color="#acf934" @change="switch1Change" :checked="isContentRecommendations"
  31. class="custom-switch" style="transform: scale(0.7)" />
  32. <image v-else class="arrow" src="../../static/me/arrow_right_gray.png" mode="widthFix"></image>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 版本信息 -->
  38. <view class="version-info">
  39. <text>版本号 {{ version }}</text>
  40. </view>
  41. <!-- 退出登录按钮 -->
  42. <view class="btn_submit" @click="logout">退出登录</view>
  43. <DialogBox ref="DialogBox"></DialogBox>
  44. <CustomerServicePopup ref="customerServicePopup"></CustomerServicePopup>
  45. </view>
  46. </template>
  47. <script>
  48. import CustomerServicePopup from "@/components/CustomerServicePopup/CustomerServicePopup.vue";
  49. import { getStorage, setStorage, removeStorage } from "@/common/util.js";
  50. import { mapState, mapMutations ,mapGetters} from 'vuex';
  51. export default {
  52. components: { CustomerServicePopup },
  53. computed: {
  54. ...mapState('rightsManagement',['isContentRecommendation']),
  55. ...mapGetters('rightsManagement',['isContent'])
  56. },
  57. data() {
  58. return {
  59. title: "",
  60. sel: 1,
  61. myinfo: {},
  62. version: "",
  63. basicSettings: [
  64. {
  65. name: "账户与安全",
  66. desc: "",
  67. path: "/pages/my/security",
  68. icon: "../../static/me/wd_icon_zhanghuyuanquan.png",
  69. propup: "",
  70. },
  71. {
  72. name: "基本资料",
  73. desc: "",
  74. path: "/pages/my/editInfo",
  75. icon: "../../static/me/wd_icon_jibenziliao.png",
  76. propup: "",
  77. },
  78. {
  79. name: "青少年模式",
  80. switch: 0,
  81. desc: "",
  82. // 'path': '/pages/my/idcheck',实名认证
  83. path: "/pages/my/adolescent",
  84. icon: "../../static/me/wd_icon_qingshaonianmoshi.png",
  85. propup: "",
  86. },
  87. ],
  88. moreSettings: [
  89. {
  90. name: "通知设置",
  91. desc: "",
  92. path: "pushSet",
  93. icon: "../../static/me/wd_icon_tonzhishezhi.png",
  94. propup: "",
  95. },
  96. {
  97. name: "服务条款",
  98. desc: "",
  99. path: "/pages/AboutUs/xieyi",
  100. icon: "../../static/me/wd_icon_fuwutiaokuan.png",
  101. propup: "",
  102. },
  103. {
  104. name: "接收内容推荐",
  105. switch: 1,
  106. desc: "",
  107. path: "",
  108. icon: "../../static/me/wd_icon_jieshouneirongtuijian.png",
  109. propup: "",
  110. },
  111. {
  112. name: "联系客服",
  113. desc: "",
  114. path: "kefu",
  115. icon: "../../static/me/wd_icon_lianxikefu.png",
  116. propup: "customPopup",
  117. },
  118. ],
  119. isContentRecommendations: true,
  120. };
  121. },
  122. onLoad() {
  123. this.getAppVersion();
  124. },
  125. onShow() {
  126. this.loadData();
  127. if (this.isContent) {
  128. this.isContentRecommendations = true
  129. } else {
  130. this.isContentRecommendations = false
  131. }
  132. },
  133. methods: {
  134. ...mapMutations('rightsManagement',[ 'setIsContentRecommendation']),
  135. ...mapMutations('switchingModule', ['deleteInformation']),
  136. openCustomPopup() {
  137. this.$refs.customerServicePopup.open();
  138. },
  139. getAppVersion() {
  140. uni.getSystemInfo({
  141. success: (info) => {
  142. // app系统环境
  143. let appPlatform = info.platform;
  144. console.log("appPlatform", info);
  145. // #ifdef H5
  146. this.version = "V" + info.appVersion;
  147. // #endif
  148. // #ifdef APP-PLUS
  149. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  150. this.version = "V" + wgtinfo.version;
  151. });
  152. // #endif
  153. },
  154. });
  155. },
  156. switch1Change(e) {
  157. this.setIsContentRecommendation(e.detail.value);
  158. },
  159. onBack() { },
  160. chkSel() {
  161. if (this.sel == 1) {
  162. this.sel = 0;
  163. } else {
  164. this.sel = 1;
  165. }
  166. },
  167. goPage(page) {
  168. if (page == "delete") {
  169. this.DelMem();
  170. } else if (page == "yszc") {
  171. // #ifdef APP-PLUS
  172. plus.runtime.openURL("https://e.zhichao.art/web/yszc.php"); // plus.runtime.openWeb(href);
  173. // #endif
  174. // #ifdef H5
  175. window.open("https://e.zhichao.art/web/yszc.php");
  176. // #endif
  177. } else if (page == "kefu") {
  178. // let that = this;
  179. // // #ifdef APP-PLUS
  180. // plus.share.getServices(res => {
  181. // const wechat = res.find(i => i.id === 'weixin')
  182. // if (wechat) {
  183. // wechat.openCustomerServiceChat({
  184. // corpid: 'wwbc06aa8311b6ac08',
  185. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  186. // url: that.myinfo.wxkf
  187. // }, src => {
  188. // console.log("success:")
  189. // }, err => {
  190. // console.log("error:")
  191. // })
  192. // } else {
  193. // uni.showToast({
  194. // title: '没有检测到微信,请先安装',
  195. // icon: "error"
  196. // });
  197. // }
  198. // });
  199. // // #endif
  200. this.openCustomPopup();
  201. } else if (page == "pushSet") {
  202. // #ifdef APP-PLUS
  203. if (uni.getSystemInfoSync().platform === 'android') {
  204. const main = plus.android.runtimeMainActivity();
  205. const NotificationManagerCompat = plus.android.importClass('androidx.core.app.NotificationManagerCompat');
  206. const Context = plus.android.importClass('android.content.Context');
  207. // 获取NotificationManagerCompat实例
  208. const notificationManager = NotificationManagerCompat.from(main);
  209. // 检查通知权限
  210. const areNotificationsEnabled = notificationManager.areNotificationsEnabled();
  211. if (areNotificationsEnabled) {
  212. uni.showToast({
  213. title: '通知权限已开启',
  214. icon: 'success'
  215. });
  216. } else {
  217. // 引导用户去设置页面开启通知
  218. uni.showModal({
  219. title: "开启通知",
  220. content: "为了及时接收重要消息,请开启通知权限",
  221. cancelText: "取消",
  222. confirmText: "确定",
  223. success: (res) => {
  224. if (res.confirm) {
  225. const Intent = plus.android.importClass('android.content.Intent');
  226. const Settings = plus.android.importClass('android.provider.Settings');
  227. const Uri = plus.android.importClass('android.net.Uri');
  228. const intent = new Intent();
  229. intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
  230. intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName());
  231. main.startActivity(intent);
  232. }
  233. },
  234. });
  235. }
  236. } else {
  237. // iOS
  238. const UIApplication = plus.ios.import("UIApplication");
  239. const NSURL = plus.ios.import("NSURL");
  240. const setting = NSURL.URLWithString("app-settings:");
  241. const application = UIApplication.sharedApplication();
  242. application.openURL(setting);
  243. }
  244. // #endif
  245. // #ifdef H5
  246. uni.showToast({
  247. title: 'H5环境不支持此功能',
  248. icon: 'none'
  249. });
  250. // #endif
  251. } else if (page != "") {
  252. uni.navigateTo({
  253. url: page,
  254. });
  255. }
  256. },
  257. DelMem() {
  258. var that = this;
  259. this.$refs["DialogBox"]
  260. .confirm({
  261. title: "警告",
  262. content:
  263. "1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。",
  264. DialogType: "inquiry",
  265. btn1: "否",
  266. btn2: "是",
  267. animation: 0,
  268. })
  269. .then(() => {
  270. uni.request({
  271. url: that.$apiHost + "/My/delete", //检测是否已绑定
  272. data: {
  273. uuid: getApp().globalData.uuid,
  274. },
  275. header: {
  276. "content-type": "application/json", //自定义请求头信息
  277. },
  278. success: (res) => {
  279. uni.removeStorageSync("wapptoken");
  280. uni.redirectTo({
  281. url: "/pages/login/login",
  282. });
  283. },
  284. });
  285. });
  286. },
  287. loadData() {
  288. console.log({
  289. uuid: getApp().globalData.uuid,
  290. skey: getApp().globalData.skey,
  291. });
  292. uni.request({
  293. url: this.$apiHost + "/Web/getinfo",
  294. data: {
  295. uuid: getApp().globalData.uuid,
  296. },
  297. header: {
  298. "content-type": "application/json",
  299. sign: getApp().globalData.headerSign,
  300. },
  301. success: (res) => {
  302. console.log("----:", res.data);
  303. this.myinfo = res.data;
  304. },
  305. complete: (com) => {
  306. // uni.hideLoading();
  307. },
  308. fail: (e) => {
  309. console.log("----e:", e);
  310. },
  311. });
  312. },
  313. EditNickname() {
  314. let that = this;
  315. this.$refs["DialogBox"]
  316. .confirm({
  317. title: "更改昵称",
  318. placeholder: "请输入修改的昵称",
  319. value: that.myinfo.nickname,
  320. DialogType: "input",
  321. animation: 0,
  322. })
  323. .then((res) => {
  324. if (res.value.length < 1) {
  325. uni.showToast({
  326. title: "请输入有效的昵称",
  327. icon: "none",
  328. });
  329. return;
  330. }
  331. that.myinfo.nickname = res.value;
  332. let obj2 = {
  333. nickname: res.value,
  334. };
  335. const postData = Object.assign(
  336. {},
  337. getApp().globalData.postHeader,
  338. obj2
  339. );
  340. uni.request({
  341. url: that.$apiHost + "/Gushi/editinfo", //检测是否已绑定
  342. data: postData,
  343. method: "POST",
  344. header: {
  345. "content-type": "application/json", //自定义请求头信息
  346. "Access-Control-Allow-Origin": "*",
  347. },
  348. success: (res) => {
  349. uni.showToast({
  350. title: res.data.str,
  351. icon: "none",
  352. });
  353. },
  354. });
  355. });
  356. },
  357. logout() {
  358. this.$refs["DialogBox"]
  359. .confirm({
  360. title: "提示",
  361. content: "确定要退出登录吗?",
  362. DialogType: "inquiry",
  363. btn1: "取消",
  364. btn2: "确定",
  365. animation: 0,
  366. })
  367. .then(() => {
  368. uni.removeStorageSync("wapptoken");
  369. uni.removeStorageSync("nickname");
  370. uni.removeStorageSync("avator");
  371. uni.removeStorageSync("mobile");
  372. uni.removeStorageSync("uuid");
  373. uni.removeStorageSync("user_id");
  374. uni.removeStorageSync("is_login");
  375. removeStorage("isContentRecommendation");
  376. this.deleteInformation();
  377. uni.redirectTo({
  378. url: "/pages/login/login",
  379. });
  380. });
  381. },
  382. },
  383. };
  384. </script>
  385. <style scoped lang="scss">
  386. @import "setting.scss";
  387. </style>