app-quick-navigation.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. console.log(this.mall.setting)
  157. } else {
  158. let setting = this.mall.setting;
  159. item = {
  160. closedPicUrl: setting.quick_navigation_closed_pic,
  161. openedPicUrl: setting.quick_navigation_opened_pic,
  162. customerService: {
  163. opened: setting.is_customer_services == 1,
  164. picUrl: setting.customer_services_pic,
  165. open_type: 'contact',
  166. },
  167. home: {
  168. opened: setting.is_quick_home == 1 ? this.oldData.home.opened : false,
  169. picUrl: setting.quick_home_pic,
  170. open_type: 'redirect',
  171. link_url: '/pages/index/index',
  172. },
  173. mApp: {
  174. appId: setting.small_app_id,
  175. opened: setting.is_small_app == 1,
  176. page: setting.small_app_url,
  177. picUrl: setting.small_app_pic,
  178. open_type: 'app',
  179. },
  180. mapNav: {
  181. opened: setting.is_quick_map == 1,
  182. address: setting.quick_map_address,
  183. latitude: setting.latitude,
  184. longitude: setting.longitude,
  185. picUrl: setting.quick_map_pic,
  186. open_type: 'map',
  187. },
  188. tel: {
  189. opened: setting.is_dial == 1,
  190. number: setting.contact_tel,
  191. picUrl: setting.dial_pic,
  192. open_type: 'tel',
  193. },
  194. web: {
  195. opened: setting.is_web_service == 1,
  196. url: '/pages/web/web?url=' + setting.web_service_url,
  197. picUrl: setting.web_service_pic,
  198. open_type: 'web',
  199. },
  200. customize: {
  201. opened: setting.is_quick_customize == 1,
  202. picUrl: setting.quick_customize_pic,
  203. link_url: setting.quick_customize_link_url,
  204. params: setting.quick_customize_new_params,
  205. open_type: setting.quick_customize_open_type,
  206. },
  207. navStyle: setting.quick_navigation_style,
  208. navSwitch: setting.is_quick_navigation,
  209. }
  210. }
  211. console.log(item)
  212. return item;
  213. },
  214. ...mapState({
  215. mall: state => state.mallConfig.mall,
  216. plugin: state => state.mallConfig.plugin
  217. }),
  218. ...mapGetters('iPhoneX', {
  219. getBoolEmpty: 'getBoolEmpty'
  220. }),
  221. },
  222. watch: {
  223. oldData: {
  224. handler: function () {
  225. let pages = getCurrentPages();
  226. let currPage = null;
  227. if (pages.length) {
  228. currPage = pages[pages.length - 1];
  229. }
  230. // #ifndef MP-TOUTIAO
  231. this.currentRoute = `/${currPage.route.split('?')[0]}`;
  232. // #endif
  233. // #ifdef MP-TOUTIAO
  234. this.currentRoute = `/${currPage.__route__.split('?')[0]}`;
  235. // #endif
  236. if (this.currentRoute === '/pages/index/index') {
  237. this.oldData.home.opened = true;
  238. // this.$emit('input', this.oldData);
  239. } else {
  240. this.oldData.home.opened = true;
  241. }
  242. },
  243. immediate: true,
  244. }
  245. },
  246. methods: {
  247. webService() {
  248. function f(url) {
  249. uni.navigateTo({
  250. url: url
  251. });
  252. }
  253. if (typeof this.plugin.dianqilai === "undefined") {
  254. f(this.newData.web.url);
  255. } else {
  256. this.$subscribe(this.plugin.dianqilai.template_message_captain).then(e => {
  257. f(this.newData.web.url);
  258. }).catch(e => {
  259. f(this.newData.web.url);
  260. })
  261. }
  262. }
  263. }
  264. }
  265. </script>
  266. <style scoped lang="scss">
  267. .app-quick {
  268. width: #{80rpx};
  269. min-height: #{80rpx};
  270. position: fixed;
  271. bottom: #{210rpx};
  272. right: #{50rpx};
  273. z-index: 1600;
  274. }
  275. .app-content {
  276. transition: height 2s;
  277. overflow: hidden;
  278. /*position: absolute;*/
  279. /*top: 0;*/
  280. width: #{80rpx};
  281. }
  282. .app-height {
  283. height: 0;
  284. }
  285. .app-view-navigation {
  286. width: #{80rpx};
  287. height: #{80rpx};
  288. margin-bottom: #{24rpx};
  289. }
  290. .app-navigation {
  291. width: #{80rpx};
  292. height: #{80rpx};
  293. background-size: 99% 99%;
  294. background-repeat: no-repeat;
  295. border-radius: 50%;
  296. }
  297. .app-quick-navigation {
  298. background-image: url("../../../static/image/icon/quick-navigation.png");
  299. }
  300. .app-collapse {
  301. background-image: url("../../../static/image/icon/collapse.png");
  302. }
  303. .app-icon {
  304. width: #{80rpx};
  305. height: #{80rpx};
  306. border-radius: 50%;
  307. background-position: center;
  308. background-size: cover;
  309. background-repeat: no-repeat;
  310. }
  311. </style>