index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view :style="privacyPolicyModel?'overflow: hidden':'overflow: unset'">
  3. <view class="fixed_top_status_bar"></view>
  4. <!-- #ifdef APP-PLUS -->
  5. <view class="privacy_policy_model" v-if="privacyPolicyModel" @touchmove.stop.prevent="moveHandle">
  6. <view class="privacy_model" @touchmove.stop.prevent="moveHandle" @touchstart.stop="()=>{}" >
  7. <view class="privacy_model_title">{{$L('用户隐私政策')}}</view>
  8. <scroll-view class="privacy_policy" scroll-y @touchmove.stop.prevent="moveHandle">
  9. <rich-text :nodes="privacyPolicyHtml"></rich-text>
  10. </scroll-view>
  11. <view class="privacy_model_confirm" @click="confirmPrivacy">{{$L('同意,继续使用')}}</view>
  12. <view class="privacy_model_cancel" @click="cancelPrivacy">{{$L('不同意,退出APP')}}>></view>
  13. </view>
  14. </view>
  15. <!-- #endif -->
  16. <home-deco :deco_info="deco_data" :width='width' :height='height' :home_page_img='home_page_img' :is_show_top="true" :home_is_show_top_cat="home_is_show_top_cat" :is_from_found="false" type="home" :overflow="privacyPolicyModel"></home-deco>
  17. </view>
  18. </template>
  19. <script>
  20. import HomeDeco from '@/components/home_deco.vue'
  21. import privacyPolicy from "@/static/app-plus/privacyPolicy.js";
  22. import {
  23. mapState,
  24. mapMutations
  25. } from 'vuex';
  26. export default {
  27. data() {
  28. return {
  29. deco_data:[] ,//首页装修数据
  30. home_is_show_top_cat:true ,//是否显示顶部分类,默认显示
  31. home_page_img:[],
  32. width:'',
  33. height:'',
  34. shareData:{},
  35. privacyPolicyHtml:'', //隐私政策协议的富文本
  36. privacyPolicyModel:true,
  37. };
  38. },
  39. components: {
  40. HomeDeco
  41. },
  42. computed:{
  43. ...mapState(['hasLogin', 'userInfo', 'userCenterData'])
  44. },
  45. onLoad() {
  46. this.loadData();
  47. this.privacyPolicyHtml=privacyPolicy.user_privacy_policy_content;
  48. let privacyPolicyHtml = uni.getStorageSync('privacyPolicy');
  49. if(privacyPolicyHtml){
  50. this.privacyPolicyModel = false;
  51. }
  52. },
  53. onShow(){
  54. let privacyPolicyHtml = uni.getStorageSync('privacyPolicy');
  55. if(privacyPolicyHtml){
  56. this.privacyPolicyModel = false;
  57. }
  58. if(this.userInfo.access_token){
  59. this.$request({
  60. url: 'v3/member/front/member/getInfo',
  61. }).then(res => {
  62. if (res.state == 200) {
  63. this.setUserCenterData(res.data);
  64. }
  65. }).catch((e) => {})
  66. }
  67. },
  68. /**
  69. * 用户点击右上角分享
  70. */
  71. onShareAppMessage: function () {
  72. const {
  73. shareData
  74. } = this;
  75. return shareData;
  76. },
  77. methods: {
  78. ...mapMutations(['login', 'setUserCenterData']),
  79. async loadData() {
  80. uni.showLoading({
  81. title:'加载中...'
  82. })
  83. // #ifdef H5
  84. this.client = 'h5'
  85. // #endif
  86. // #ifdef APP-PLUS
  87. switch(uni.getSystemInfoSync().platform){
  88. case 'android':
  89. this.client = 'android'
  90. break;
  91. case 'ios':
  92. this.client = 'ios'
  93. break;
  94. default:
  95. break;
  96. }
  97. // #endif
  98. // #ifdef MP
  99. this.client = 'weixinXcx'
  100. // #endif
  101. let param = {}
  102. param.url = 'v3/system/front/deco/index?os='+this.client
  103. param.method = 'GET'
  104. this.$request(param).then(res => {
  105. if (res.state == 200) {
  106. if(JSON.stringify(res.data) == "{}"){
  107. this.deco_data = null;
  108. uni.hideLoading();
  109. return
  110. }
  111. if(res.data.data != ''){
  112. this.deco_data = JSON.parse(res.data.data)
  113. }else{
  114. this.deco_data = null
  115. }
  116. // #ifdef MP
  117. this.shareData={
  118. title: res.data.siteName,
  119. path: '/pages/index/index',
  120. imageUrl: res.data.xcxImage
  121. }
  122. // #endif
  123. if(res.data.showTip != null){
  124. this.home_page_img = JSON.parse(res.data.showTip)
  125. const {windowWidth,windowHeight} = uni.getSystemInfoSync();
  126. this.width = this.home_page_img[0].width || windowWidth*0.75 * 1.8;
  127. this.height = this.home_page_img[0].height || windowHeight*0.56 * 1.8;
  128. }else{
  129. this.home_page_img = []
  130. }
  131. if(this.deco_data && this.deco_data.length != undefined && this.deco_data.length>0){
  132. this.home_is_show_top_cat = this.deco_data[0].type == 'top_cat_nav'?true:false;
  133. }
  134. uni.hideLoading()
  135. }
  136. })
  137. },
  138. //阻止模态框下页面滚动
  139. moveHandle(){},
  140. //同意,继续使用
  141. confirmPrivacy(){
  142. this.privacyPolicyModel = false;
  143. uni.setStorageSync('privacyPolicy',this.privacyPolicyHtml);
  144. },
  145. //不同意,退出app
  146. cancelPrivacy(){
  147. this.privacyPolicyModel = false;
  148. uni.clearStorageSync('privacyPolicy');
  149. //退出app
  150. // #ifdef APP-PLUS
  151. if (plus.os.name.toLowerCase() === 'android') {
  152. plus.runtime.quit();
  153. }
  154. else{
  155. const threadClass = plus.ios.importClass("NSThread");
  156. const mainThread = plus.ios.invoke(threadClass, "mainThread");
  157. plus.ios.invoke(mainThread, "exit");
  158. plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
  159. }
  160. // #endif
  161. }
  162. },
  163. }
  164. </script>
  165. <style lang="scss">
  166. .fixed_top_status_bar {
  167. position: fixed;
  168. /* #ifdef APP-PLUS */
  169. height: var(--status-bar-height);
  170. /* #endif */
  171. /* #ifndef APP-PLUS */
  172. height: 0;
  173. /* #endif */
  174. top: 0;
  175. left: 0;
  176. right: 0;
  177. z-index: 99;
  178. background: #fff;
  179. }
  180. page{
  181. background: #F5F5F5;
  182. }
  183. .privacy_policy_model{
  184. width: 750rpx;
  185. height:100vh;
  186. background: rgba(0,0,0,0.7);
  187. position: fixed;
  188. top: 0;
  189. left: 0;
  190. z-index: 9999999;
  191. overflow: hidden;
  192. .privacy_model{
  193. width: 625rpx;
  194. height:70vh;
  195. background: #FFFFFF;
  196. border-radius: 15rpx;
  197. margin: 0 auto;
  198. margin-top: 17vh;
  199. padding-bottom: 24rpx;
  200. box-sizing: border-box;
  201. display: flex;
  202. flex-direction: column;
  203. justify-content: space-between;
  204. .privacy_model_title{
  205. height: 104rpx;
  206. font-size: 34rpx;
  207. font-family: Source Han Sans CN;
  208. font-weight: bold;
  209. color: #000000;
  210. line-height: 104rpx;
  211. text-align: center;
  212. border-bottom: 1rpx solid #F2F2F2;
  213. }
  214. .privacy_policy{
  215. width: 625rpx;
  216. height: 50vh;
  217. padding:0 43rpx;
  218. box-sizing: border-box;
  219. }
  220. .privacy_model_confirm{
  221. width: 542rpx;
  222. height: 72rpx;
  223. background: linear-gradient(90deg, #FC1C1C 0%, #FF7918 100%);
  224. border-radius: 36rpx;
  225. font-size: 28rpx;
  226. font-family: Source Han Sans CN;
  227. font-weight: 400;
  228. color: #FFFFFF;
  229. line-height: 72rpx;
  230. text-align: center;
  231. margin: 20rpx auto;
  232. }
  233. .privacy_model_cancel{
  234. font-size: 28rpx;
  235. font-family: Source Han Sans CN;
  236. font-weight: 400;
  237. color: #FF991E;
  238. text-align: center;
  239. line-height: 28rpx;
  240. }
  241. }
  242. }
  243. </style>