setting.vue 12 KB

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