app-quick-navigation.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="app-quick" v-if="newData.navSwitch == 1" :style="{bottom: getBoolEmpty.XBoolean ? '260rpx' : '210rpx'}">
  3. <view class="app-content" :class="[`${(collapse === false && newData.navStyle == 1) ? 'app-height' : ''}`]">
  4. <view class="app-view-navigation" v-if="newData.home.opened">
  5. <app-jump-button form :open_type="newData.home.open_type" :url="newData.home.link_url">
  6. <icon class="app-icon" :style="{backgroundImage: `url(${newData.home.picUrl})`}"></icon>
  7. </app-jump-button>
  8. </view>
  9. <!-- #ifndef MP-TOUTIAO -->
  10. <view class="app-view-navigation" v-if="newData.customerService.opened">
  11. <app-jump-button form :open_type="newData.customerService.open_type">
  12. <icon class="app-icon" :style="{backgroundImage: `url(${newData.customerService.picUrl})`}"></icon>
  13. </app-jump-button>
  14. </view>
  15. <!-- #endif -->
  16. <view class="app-view-navigation" v-if="newData.tel.opened">
  17. <app-jump-button form :open_type="newData.tel.open_type" :number="newData.tel.number">
  18. <icon class="app-icon" :style="{backgroundImage: `url(${newData.tel.picUrl})`}"></icon>
  19. </app-jump-button>
  20. </view>
  21. <view class="app-view-navigation" v-if="newData.web.opened">
  22. <app-jump-button form :open_type="newData.web.open_type" :url="newData.web.url">
  23. <icon class="app-icon" :style="{backgroundImage: `url(${newData.web.picUrl})`}"></icon>
  24. </app-jump-button>
  25. </view>
  26. <!-- #ifndef MP-TOUTIAO -->
  27. <view class="app-view-navigation" v-if="newData.mApp.opened">
  28. <app-jump-button form :open_type="newData.mApp.open_type" :app-id="newData.mApp.appId" :path="newData.mApp.page">
  29. <icon class="app-icon" :style="{backgroundImage: `url(${newData.mApp.picUrl})`}"></icon>
  30. </app-jump-button>
  31. </view>
  32. <!-- #endif -->
  33. <view class="app-view-navigation" v-if="newData.mapNav.opened">
  34. <app-jump-button
  35. form
  36. :open_type="newData.mapNav.open_type"
  37. :latitude="newData.mapNav.latitude"
  38. :longitude="newData.mapNav.longitude"
  39. :address="newData.mapNav.address"
  40. >
  41. <icon class="app-icon" :style="{backgroundImage: `url(${newData.mapNav.picUrl})`}"></icon>
  42. </app-jump-button>
  43. </view>
  44. <view class="app-view-navigation" v-if="newData.customize.opened">
  45. <app-jump-button form :open_type="newData.customize.open_type" :url="newData.customize.link_url"
  46. :params="newData.customize.params">
  47. <icon class="app-icon" :style="{backgroundImage: `url(${newData.customize.picUrl})`}"></icon>
  48. </app-jump-button>
  49. </view>
  50. </view>
  51. <view class="app-navigation" v-if="newData.navStyle == 1"
  52. :style="{backgroundImage: `url(${!collapse ? newData.openedPicUrl : newData.closedPicUrl})`}"
  53. :class="{'app-quick-navigation': !collapse, 'app-collapse': collapse}"
  54. @click="collapse = !collapse"></view>
  55. </view>
  56. </template>
  57. <script>
  58. import {mapGetters, mapState} from "vuex";
  59. export default {
  60. name: `app-quick-navigation`,
  61. props: {
  62. value: {
  63. type: Object,
  64. default: function () {
  65. return {
  66. closedPicUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  67. customerService: {
  68. opened: false,
  69. picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  70. },
  71. home: {
  72. opened: false,
  73. picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  74. },
  75. mApp: {
  76. appId: '',
  77. opened: false,
  78. page: '',
  79. picUrl: '',
  80. },
  81. mapNav: {
  82. address: '南湖',
  83. latitude: '30.762457',
  84. location: '',
  85. longitude: '120.763779',
  86. opened: false,
  87. picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg'
  88. },
  89. navStyle: 1,
  90. navSwitch: 1,
  91. openedPicUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  92. tel: {
  93. number: '1885813481',
  94. opened: false,
  95. picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  96. },
  97. useMallConfig: false,
  98. web: {
  99. opened: true,
  100. picUrl: 'http://www.bangdian.net/web/uploads/mall51/20190724/3d3abd2944d5d32b9a9780fd3525bb50.jpg',
  101. url: 'www.baidu.com',
  102. },
  103. customize: {},
  104. }
  105. }
  106. },
  107. useMallConfig: {
  108. type: Boolean,
  109. default() {
  110. return true;
  111. }
  112. }
  113. },
  114. data() {
  115. return {
  116. collapse: false,
  117. oldData: this.value,
  118. }
  119. },
  120. computed: {
  121. newData: function () {
  122. let item = {};
  123. if (!this.useMallConfig) {
  124. item = {
  125. customerService: {
  126. open_type: 'contact'
  127. },
  128. home: {
  129. open_type: 'redirect',
  130. link_url: '/pages/index/index'
  131. },
  132. mApp: {
  133. open_type: 'app'
  134. },
  135. mapNav: {
  136. open_type: 'map'
  137. },
  138. tel: {
  139. open_type: 'tel'
  140. },
  141. web: {
  142. open_type: 'web'
  143. },
  144. customize: {
  145. open_type: '',
  146. },
  147. };
  148. for (let key in this.oldData) {
  149. if (key === 'customerService' || key === 'home' || key === 'mApp' || key === 'mapNav' || key === 'tel') {
  150. item[key] = {...item[key], ...this.oldData[key]}
  151. } else if (key === 'web') {
  152. let url = `../web/web?url=${this.oldData[key].url}`;
  153. item.web = {...item.web, ...this.oldData[key], url}
  154. } else {
  155. item[key] = this.oldData[key];
  156. }
  157. }
  158. } else {
  159. let setting = this.mall.setting;
  160. item = {
  161. closedPicUrl: setting.quick_navigation_closed_pic,
  162. openedPicUrl: setting.quick_navigation_opened_pic,
  163. customerService: {
  164. opened: setting.is_customer_services == 1,
  165. picUrl: setting.customer_services_pic,
  166. open_type: 'contact',
  167. },
  168. home: {
  169. opened: setting.is_quick_home == 1 ? this.oldData.home.opened : false,
  170. picUrl: setting.quick_home_pic,
  171. open_type: 'redirect',
  172. link_url: '/pages/index/index',
  173. },
  174. mApp: {
  175. appId: setting.small_app_id,
  176. opened: setting.is_small_app == 1,
  177. page: setting.small_app_url,
  178. picUrl: setting.small_app_pic,
  179. open_type: 'app',
  180. },
  181. mapNav: {
  182. opened: setting.is_quick_map == 1,
  183. address: setting.quick_map_address,
  184. latitude: setting.latitude,
  185. longitude: setting.longitude,
  186. picUrl: setting.quick_map_pic,
  187. open_type: 'map',
  188. },
  189. tel: {
  190. opened: setting.is_dial == 1,
  191. number: setting.contact_tel,
  192. picUrl: setting.dial_pic,
  193. open_type: 'tel',
  194. },
  195. web: {
  196. opened: setting.is_web_service == 1,
  197. url: '/pages/web/web?url=' + setting.web_service_url,
  198. picUrl: setting.web_service_pic,
  199. open_type: 'web',
  200. },
  201. customize: {
  202. opened: setting.is_quick_customize == 1,
  203. picUrl: setting.quick_customize_pic,
  204. link_url: setting.quick_customize_link_url,
  205. params: setting.quick_customize_new_params,
  206. open_type: setting.quick_customize_open_type,
  207. },
  208. navStyle: setting.quick_navigation_style,
  209. navSwitch: setting.is_quick_navigation,
  210. }
  211. }
  212. return item;
  213. },
  214. ...mapState({
  215. mall: state => state.mallConfig.mall,
  216. }),
  217. ...mapGetters('iPhoneX', {
  218. getBoolEmpty: 'getBoolEmpty'
  219. }),
  220. },
  221. watch: {
  222. oldData: {
  223. handler: function () {
  224. let pages = getCurrentPages();
  225. let currPage = null;
  226. if (pages.length) {
  227. currPage = pages[pages.length - 1];
  228. }
  229. // #ifndef MP-TOUTIAO
  230. this.currentRoute = `/${currPage.route.split('?')[0]}`;
  231. // #endif
  232. // #ifdef MP-TOUTIAO
  233. this.currentRoute = `/${currPage.__route__.split('?')[0]}`;
  234. // #endif
  235. if (this.currentRoute === '/pages/index/index') {
  236. this.oldData.home.opened = false;
  237. // this.$emit('input', this.oldData);
  238. } else {
  239. this.oldData.home.opened = true;
  240. }
  241. },
  242. immediate: true,
  243. }
  244. }
  245. }
  246. </script>
  247. <style scoped lang="scss">
  248. .app-quick {
  249. width: #{80rpx};
  250. min-height: #{80rpx};
  251. position: fixed;
  252. bottom: #{210rpx};
  253. right: #{50rpx};
  254. z-index: 1600;
  255. }
  256. .app-content {
  257. transition: height 2s;
  258. overflow: hidden;
  259. /*position: absolute;*/
  260. /*top: 0;*/
  261. width: #{80rpx};
  262. }
  263. .app-height {
  264. height: 0;
  265. }
  266. .app-view-navigation {
  267. width: #{80rpx};
  268. height: #{80rpx};
  269. margin-bottom: #{24rpx};
  270. }
  271. .app-navigation {
  272. width: #{80rpx};
  273. height: #{80rpx};
  274. background-size: 99% 99%;
  275. background-repeat: no-repeat;
  276. border-radius: 50%;
  277. }
  278. .app-quick-navigation {
  279. background-image: url("../../../static/image/icon/quick-navigation.png");
  280. }
  281. .app-collapse {
  282. background-image: url("../../../static/image/icon/collapse.png");
  283. }
  284. .app-icon {
  285. width: #{80rpx};
  286. height: #{80rpx};
  287. border-radius: 50%;
  288. background-position: center;
  289. background-size: cover;
  290. background-repeat: no-repeat;
  291. }
  292. </style>