app-quick-navigation.vue 13 KB

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