quick-nav.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view>
  3. <!-- 开启事件 -->
  4. <movable-area v-if="quick_status == 1" :class="'quick-movable-container '+ common_ent" :style="'height: calc(100% - '+height_dec+'rpx);top:'+top+'rpx;'">
  5. <movable-view direction="all" :x="x" :y="y" :animation="false" class="quick-event-submit bg-main" @tap="quick_open_event">
  6. <image :src="common_static_url+'quick-icon.png'" mode="widthFix"></image>
  7. </movable-view>
  8. </movable-area>
  9. <!-- 弹窗 -->
  10. <component-popup :propShow="popup_status" :propIsBar="propIsBar" propPosition="bottom" @onclose="quick_close_event">
  11. <view :class="'nav-popup-container '+common_ent">
  12. <view class="close oh">
  13. <view class="icon-right" @tap.stop="quick_close_event">
  14. <icon type="clear" size="20"></icon>
  15. </view>
  16. </view>
  17. <view class="nav-popup-content">
  18. <view v-if="data_list.length > 0" class="nav-data-list">
  19. <view v-for="(item, index) in data_list" :key="index" class="item cp">
  20. <view :class="'item-content '+((item.bg_color || null) == null ? 'item-exposed' : '')" :data-value="item.event_value" :data-type="item.event_type" @tap="navigation_event" :style="((item.bg_color || null) == null ? '' : 'background-color:'+item.bg_color+';')">
  21. <image :src="item.images_url" mode="aspectFit"></image>
  22. </view>
  23. <view class="title">{{item.name}}</view>
  24. </view>
  25. </view>
  26. <view v-else>
  27. <!-- 提示信息 -->
  28. <component-no-data :propStatus="0"></component-no-data>
  29. </view>
  30. </view>
  31. </view>
  32. </component-popup>
  33. </view>
  34. </template>
  35. <script>
  36. const app = getApp();
  37. import componentPopup from "../popup/popup";
  38. import componentNoData from "../no-data/no-data";
  39. var common_static_url = app.globalData.get_static_url('common');
  40. export default {
  41. data() {
  42. return {
  43. common_static_url: common_static_url,
  44. popup_status: false,
  45. quick_status: 0,
  46. data_list: [],
  47. system: null,
  48. x: 0,
  49. y: 0,
  50. top: 0,
  51. height_dec: 0,
  52. is_first: 1,
  53. common_ent: ''
  54. };
  55. },
  56. components: {
  57. componentPopup,
  58. componentNoData
  59. },
  60. props: {
  61. propIsBar: {
  62. type: Boolean,
  63. default: false
  64. },
  65. propIsNav: {
  66. type: Boolean,
  67. default: false
  68. },
  69. propIsGrayscale: {
  70. type:Number,
  71. default: 0
  72. }
  73. },
  74. // 属性值改变监听
  75. watch: {
  76. // 是否灰度
  77. propIsGrayscale(value, old_value) {
  78. this.common_ent = (value == 1) ? 'grayscale' : '';
  79. }
  80. },
  81. // 页面被展示
  82. created: function() {
  83. this.init_config();
  84. // 页面是否定义导航
  85. var value = this.propIsNav ? 170 : 0;
  86. this.top = value
  87. this.height_dec = value;
  88. // #ifdef H5 || APP
  89. this.top = 90;
  90. this.height_dec = this.propIsBar ? 190 : 90;
  91. // #endif
  92. // 非首次进入则重新初始化配置接口
  93. if (this.is_first == 0) {
  94. app.globalData.init_config();
  95. }
  96. // 数据设置
  97. var system = app.globalData.get_system_info(null, null, true);
  98. var height = app.globalData.window_height_handle(system);
  99. this.setData({
  100. is_first: 0,
  101. system: system,
  102. x: 12,
  103. y: height - 280
  104. });
  105. },
  106. methods: {
  107. // 初始化配置
  108. init_config(status) {
  109. if ((status || false) == true) {
  110. this.setData({
  111. data_list: app.globalData.get_config('quick_nav') || [],
  112. quick_status: app.globalData.get_config('config.home_navigation_main_quick_status') || 0
  113. });
  114. } else {
  115. app.globalData.is_config(this, 'init_config');
  116. }
  117. },
  118. // 弹层开启
  119. quick_open_event(e) {
  120. this.setData({
  121. popup_status: true,
  122. data_list: app.globalData.get_config('quick_nav') || []
  123. });
  124. },
  125. // 弹层关闭
  126. quick_close_event(e) {
  127. this.setData({
  128. popup_status: false
  129. });
  130. },
  131. // 操作事件
  132. navigation_event(e) {
  133. app.globalData.operation_event(e);
  134. }
  135. }
  136. };
  137. </script>
  138. <style>
  139. /**
  140. * 按钮
  141. */
  142. .quick-movable-container {
  143. position: fixed;
  144. width: 100%;
  145. height: 100%;
  146. top: 0;
  147. left: 0;
  148. background: transparent;
  149. pointer-events: none;
  150. z-index: 2;
  151. }
  152. .quick-event-submit {
  153. pointer-events: auto;
  154. width: 31px;
  155. height: 31px;
  156. border-radius: 50%;
  157. box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  158. opacity: 0.8;
  159. }
  160. .quick-event-submit image {
  161. width: 17px !important;
  162. height: 17px !important;
  163. margin: 7px auto 7px auto;
  164. display: block;
  165. }
  166. /**
  167. * 弹窗
  168. */
  169. .nav-popup-container {
  170. padding: 20rpx 10rpx 0 10rpx;
  171. background: #fff;
  172. }
  173. .nav-popup-container .close {
  174. overflow: hidden;
  175. }
  176. .nav-popup-container .close .icon-right {
  177. float: right;
  178. }
  179. .nav-popup-content {
  180. max-height: 80vh;
  181. overflow-y: scroll;
  182. overflow-x: hidden;
  183. padding-bottom: 20rpx;
  184. }
  185. /**
  186. * 内容
  187. */
  188. .nav-data-list {
  189. overflow: hidden;
  190. background: #fff;
  191. }
  192. .nav-data-list .item {
  193. width: calc(25% - 60rpx);
  194. float: left;
  195. padding: 30rpx;
  196. /* #ifdef H5 */
  197. cursor: pointer;
  198. /* #endif */
  199. }
  200. .nav-data-list .item-content {
  201. border-radius: 50%;
  202. padding: 20rpx;
  203. text-align: center;
  204. margin: 0 auto;
  205. -webkit-box-shadow: 0 2px 12px rgb(226 226 226 / 95%);
  206. box-shadow: 0 2px 12px rgb(226 226 226 / 95%);
  207. }
  208. .nav-data-list .item-content,
  209. .nav-data-list .item image {
  210. width: 70rpx !important;
  211. height: 70rpx !important;
  212. }
  213. .nav-data-list .item .item-exposed {
  214. padding: 0;
  215. -webkit-box-shadow: none;
  216. box-shadow: none;
  217. }
  218. .nav-data-list .item .item-exposed,
  219. .nav-data-list .item .item-exposed image {
  220. width: 110rpx !important;
  221. height: 110rpx !important;
  222. }
  223. .nav-data-list .item .title {
  224. margin-top: 10rpx;
  225. font-size: 28rpx !important;
  226. text-align: center;
  227. -o-text-overflow: ellipsis;
  228. text-overflow: ellipsis;
  229. overflow: hidden;
  230. white-space: nowrap;
  231. max-width: 100%;
  232. }
  233. </style>