setting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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. openCustomPopup() {
  136. this.$refs.customerServicePopup.open();
  137. },
  138. getAppVersion() {
  139. uni.getSystemInfo({
  140. success: (info) => {
  141. // app系统环境
  142. let appPlatform = info.platform;
  143. console.log("appPlatform", info);
  144. // #ifdef H5
  145. this.version = "V" + info.appVersion;
  146. // #endif
  147. // #ifdef APP-PLUS
  148. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  149. this.version = "V" + wgtinfo.version;
  150. });
  151. // #endif
  152. },
  153. });
  154. },
  155. switch1Change(e) {
  156. this.setIsContentRecommendation(e.detail.value);
  157. },
  158. onBack() { },
  159. chkSel() {
  160. if (this.sel == 1) {
  161. this.sel = 0;
  162. } else {
  163. this.sel = 1;
  164. }
  165. },
  166. goPage(page) {
  167. if (page == "delete") {
  168. this.DelMem();
  169. } else if (page == "yszc") {
  170. // #ifdef APP-PLUS
  171. plus.runtime.openURL("https://e.zhichao.art/web/yszc.php"); // plus.runtime.openWeb(href);
  172. // #endif
  173. // #ifdef H5
  174. window.open("https://e.zhichao.art/web/yszc.php");
  175. // #endif
  176. } else if (page == "kefu") {
  177. // let that = this;
  178. // // #ifdef APP-PLUS
  179. // plus.share.getServices(res => {
  180. // const wechat = res.find(i => i.id === 'weixin')
  181. // if (wechat) {
  182. // wechat.openCustomerServiceChat({
  183. // corpid: 'wwbc06aa8311b6ac08',
  184. // // url: 'https://work.weixin.qq.com/kfid/kfc4b0bcb4038d00a50'
  185. // url: that.myinfo.wxkf
  186. // }, src => {
  187. // console.log("success:")
  188. // }, err => {
  189. // console.log("error:")
  190. // })
  191. // } else {
  192. // uni.showToast({
  193. // title: '没有检测到微信,请先安装',
  194. // icon: "error"
  195. // });
  196. // }
  197. // });
  198. // // #endif
  199. this.openCustomPopup();
  200. } else if (page == "pushSet") {
  201. // #ifdef APP-PLUS
  202. if (uni.getSystemInfoSync().platform === 'android') {
  203. const main = plus.android.runtimeMainActivity();
  204. const NotificationManagerCompat = plus.android.importClass('androidx.core.app.NotificationManagerCompat');
  205. const Context = plus.android.importClass('android.content.Context');
  206. // 获取NotificationManagerCompat实例
  207. const notificationManager = NotificationManagerCompat.from(main);
  208. // 检查通知权限
  209. const areNotificationsEnabled = notificationManager.areNotificationsEnabled();
  210. if (areNotificationsEnabled) {
  211. uni.showToast({
  212. title: '通知权限已开启',
  213. icon: 'success'
  214. });
  215. } else {
  216. // 引导用户去设置页面开启通知
  217. uni.showModal({
  218. title: "开启通知",
  219. content: "为了及时接收重要消息,请开启通知权限",
  220. cancelText: "取消",
  221. confirmText: "确定",
  222. success: (res) => {
  223. if (res.confirm) {
  224. const Intent = plus.android.importClass('android.content.Intent');
  225. const Settings = plus.android.importClass('android.provider.Settings');
  226. const Uri = plus.android.importClass('android.net.Uri');
  227. const intent = new Intent();
  228. intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS);
  229. intent.putExtra(Settings.EXTRA_APP_PACKAGE, main.getPackageName());
  230. main.startActivity(intent);
  231. }
  232. },
  233. });
  234. }
  235. } else {
  236. // iOS
  237. const UIApplication = plus.ios.import("UIApplication");
  238. const NSURL = plus.ios.import("NSURL");
  239. const setting = NSURL.URLWithString("app-settings:");
  240. const application = UIApplication.sharedApplication();
  241. application.openURL(setting);
  242. }
  243. // #endif
  244. // #ifdef H5
  245. uni.showToast({
  246. title: 'H5环境不支持此功能',
  247. icon: 'none'
  248. });
  249. // #endif
  250. } else if (page != "") {
  251. uni.navigateTo({
  252. url: page,
  253. });
  254. }
  255. },
  256. DelMem() {
  257. var that = this;
  258. this.$refs["DialogBox"]
  259. .confirm({
  260. title: "警告",
  261. content:
  262. "1、注销账号是不可逆操作,该账号下所有一切资料一旦注销无法恢复;\n2、注销后,你账号下所有权益将被清除。",
  263. DialogType: "inquiry",
  264. btn1: "否",
  265. btn2: "是",
  266. animation: 0,
  267. })
  268. .then(() => {
  269. uni.request({
  270. url: that.$apiHost + "/My/delete", //检测是否已绑定
  271. data: {
  272. uuid: getApp().globalData.uuid,
  273. },
  274. header: {
  275. "content-type": "application/json", //自定义请求头信息
  276. },
  277. success: (res) => {
  278. uni.removeStorageSync("wapptoken");
  279. uni.redirectTo({
  280. url: "/pages/login/login",
  281. });
  282. },
  283. });
  284. });
  285. },
  286. loadData() {
  287. console.log({
  288. uuid: getApp().globalData.uuid,
  289. skey: getApp().globalData.skey,
  290. });
  291. uni.request({
  292. url: this.$apiHost + "/Web/getinfo",
  293. data: {
  294. uuid: getApp().globalData.uuid,
  295. },
  296. header: {
  297. "content-type": "application/json",
  298. sign: getApp().globalData.headerSign,
  299. },
  300. success: (res) => {
  301. console.log("----:", res.data);
  302. this.myinfo = res.data;
  303. },
  304. complete: (com) => {
  305. // uni.hideLoading();
  306. },
  307. fail: (e) => {
  308. console.log("----e:", e);
  309. },
  310. });
  311. },
  312. EditNickname() {
  313. let that = this;
  314. this.$refs["DialogBox"]
  315. .confirm({
  316. title: "更改昵称",
  317. placeholder: "请输入修改的昵称",
  318. value: that.myinfo.nickname,
  319. DialogType: "input",
  320. animation: 0,
  321. })
  322. .then((res) => {
  323. if (res.value.length < 1) {
  324. uni.showToast({
  325. title: "请输入有效的昵称",
  326. icon: "none",
  327. });
  328. return;
  329. }
  330. that.myinfo.nickname = res.value;
  331. let obj2 = {
  332. nickname: res.value,
  333. };
  334. const postData = Object.assign(
  335. {},
  336. getApp().globalData.postHeader,
  337. obj2
  338. );
  339. uni.request({
  340. url: that.$apiHost + "/Gushi/editinfo", //检测是否已绑定
  341. data: postData,
  342. method: "POST",
  343. header: {
  344. "content-type": "application/json", //自定义请求头信息
  345. "Access-Control-Allow-Origin": "*",
  346. },
  347. success: (res) => {
  348. uni.showToast({
  349. title: res.data.str,
  350. icon: "none",
  351. });
  352. },
  353. });
  354. });
  355. },
  356. logout() {
  357. this.$refs["DialogBox"]
  358. .confirm({
  359. title: "提示",
  360. content: "确定要退出登录吗?",
  361. DialogType: "inquiry",
  362. btn1: "取消",
  363. btn2: "确定",
  364. animation: 0,
  365. })
  366. .then(() => {
  367. uni.removeStorageSync("wapptoken");
  368. uni.removeStorageSync("nickname");
  369. uni.removeStorageSync("avator");
  370. uni.removeStorageSync("mobile");
  371. uni.removeStorageSync("uuid");
  372. uni.removeStorageSync("user_id");
  373. uni.removeStorageSync("is_login");
  374. removeStorage("isContentRecommendation");
  375. uni.redirectTo({
  376. url: "/pages/login/login",
  377. });
  378. });
  379. },
  380. },
  381. };
  382. </script>
  383. <style scoped lang="scss">
  384. @import "setting.scss";
  385. </style>