index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view class="rf-search-bar" :class="'bg-' + themeColor.name">
  3. <view
  4. class="header"
  5. :style="{width:merchantShow ? '100vw' : width+'px', marginTop: merchantShow ? 0 : inputTop+'px'}">
  6. <text> {{title}} </text>
  7. <!-- 搜索框 -->
  8. <view class="input-box" @tap="toSearch">
  9. <input
  10. disabled
  11. />
  12. <view :class="title?'wrapper2':'wrapper'">
  13. <text class="iconfont iconsousuo2"></text>
  14. <text class="keyword" >{{ placeholder }}</text>
  15. </view>
  16. </view>
  17. <view class="addr">
  18. <!-- 消息提醒 -->
  19. <!-- <text class="fa fa-bell-o" aria-hidden="true" style="color:#fff;font-size: 38upx;" ></text> -->
  20. </view>
  21. </view>
  22. <scroll-view
  23. scroll-x
  24. class="index-cate"
  25. v-if="isOpenIndexCate && categoryList.length > 0">
  26. <view
  27. v-for="(item, index) in categoryList"
  28. :key="index"
  29. class="index-cate-item"
  30. :class="tabCurrentIndex === index ? `text-${themeColor.name} active` : ''"
  31. @tap.stop="tabClick(index, item.id)"
  32. >
  33. {{ item.title }}
  34. </view>
  35. </scroll-view>
  36. <!-- <div class="box"></div> -->
  37. </view>
  38. </template>
  39. <script>
  40. // #ifdef H5
  41. import jweixin from '@/common/jweixin';
  42. // #endif
  43. import { productVirtualVerificationVerify } from '@/api/userInfo';
  44. export default {
  45. props: {
  46. headerShow: {
  47. type: Boolean,
  48. default: true
  49. },
  50. merchantData: {
  51. type: Object,
  52. default() {
  53. return {};
  54. }
  55. },
  56. merchantShow: {
  57. type: Boolean,
  58. default: false
  59. },
  60. categoryList: {
  61. type: Array,
  62. default() {
  63. return [];
  64. }
  65. },
  66. inputDisabled: {
  67. type: Boolean,
  68. default: false
  69. },
  70. placeholder: {
  71. type: String,
  72. default() {
  73. return this.$i18n.locale == 'zh'? '请输入关键字': 'Please input keywords'
  74. }
  75. },
  76. icon: {
  77. type: String,
  78. default: null
  79. },
  80. title: {
  81. type: String,
  82. default: null
  83. }
  84. },
  85. data() {
  86. return {
  87. CustomBar: this.CustomBar,
  88. searchValue: this.placeholder,
  89. appLogo: this.$mSettingConfig.appLogo,
  90. isOpenScan: this.$mSettingConfig.isOpenScan,
  91. isOpenIndexCate: this.$mSettingConfig.isOpenIndexCate,
  92. height: 0,
  93. width: 0,
  94. inputTop: 0,
  95. tabCurrentIndex: 0
  96. };
  97. },
  98. created() {
  99. let obj = {};
  100. // #ifdef MP-WEIXIN
  101. // eslint-disable-next-line
  102. obj = wx.getMenuButtonBoundingClientRect();
  103. // #endif
  104. uni.getSystemInfo({
  105. success: (res) => {
  106. this.width = obj.left || res.windowWidth;
  107. this.height = obj.top ? (obj.top + obj.height + 8) : (res.statusBarHeight + 44);
  108. this.inputTop = obj.top ? (obj.top + (obj.height - 30) / 2) : (res.statusBarHeight + 7);
  109. }
  110. });
  111. },
  112. methods: {
  113. tabClick(index, id) {
  114. this.tabCurrentIndex = index;
  115. this.$emit('tab', {
  116. id
  117. });
  118. },
  119. // 获取定位信息
  120. getCity() {
  121. this.$mRouter.push({ route: '/pages/index/location/merchant' });
  122. },
  123. discard() {
  124. },
  125. // 扫一扫
  126. link() {
  127. const _this = this;
  128. /* #ifndef H5 */
  129. uni.scanCode({
  130. success: function(res) {
  131. if (res.result.indexOf('http') !== -1) {
  132. if (res.result.indexOf(_this.$mConfig.hostUrl) !== -1) {
  133. if (
  134. res.result.indexOf('/pages/profile/profile') !== -1 ||
  135. res.result.indexOf('/pages/service/service') !== -1 ||
  136. res.result.indexOf('/pages/index/index') !== -1 ||
  137. res.result.indexOf('/pages/notify/notify') !== -1 ||
  138. res.result.indexOf('/pages/category/category') !== -1
  139. ) {
  140. _this.$mRouter.reLaunch({ route: res.result.substring(_this.$mConfig.hostUrl.length) });
  141. } else {
  142. _this.$mRouter.redirectTo({ route: res.result.substring(_this.$mConfig.hostUrl.length) });
  143. }
  144. } else {
  145. _this.$mHelper.toast('不能识别该二维码');
  146. }
  147. }
  148. },
  149. fail(res) {
  150. // 支付成功后的回调函数
  151. _this.$mHelper.toast('扫描失败:' + res.errMsg);
  152. }
  153. });
  154. /* #endif */
  155. /* #ifdef H5 */
  156. if (this.$mPayment.isWechat()) {
  157. jweixin.ready(() => {
  158. jweixin.scanQRCode({
  159. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  160. success(res) {
  161. if (res.result.indexOf('http') !== -1) {
  162. if (res.result.indexOf(_this.$mConfig.hostUrl) !== -1) {
  163. if (
  164. res.result.indexOf('/pages/profile/profile') !== -1 ||
  165. res.result.indexOf('/pages/service/service') !== -1 ||
  166. res.result.indexOf('/pages/index/index') !== -1 ||
  167. res.result.indexOf('/pages/notify/notify') !== -1 ||
  168. res.result.indexOf('/pages/category/category') !== -1
  169. ) {
  170. _this.$mRouter.reLaunch({ route: res.result.substring(_this.$mConfig.hostUrl.length) });
  171. } else {
  172. _this.$mRouter.redirectTo({ route: res.result.substring(_this.$mConfig.hostUrl.length) });
  173. }
  174. } else {
  175. _this.$mHelper.toast('不能识别该二维码');
  176. }
  177. }
  178. },
  179. fail(res) {
  180. // 支付成功后的回调函数
  181. _this.$mHelper.toast('扫描失败:' + res.errMsg);
  182. }
  183. });
  184. });
  185. } else {
  186. this.$mHelper.toast('请在微信H5进行相关操作');
  187. }
  188. /* #endif */
  189. },
  190. async toSearch() {
  191. await this.$emit('search', {
  192. searchValue: this.searchValue
  193. });
  194. }
  195. }
  196. };
  197. </script>
  198. <style lang="scss" scoped>
  199. .keyword {
  200. color: #999999;
  201. font-size: 13px;
  202. margin-left: 10px;
  203. }
  204. .rf-search-bar {
  205. position: fixed;
  206. width: 100%;
  207. top: 0;
  208. left: 0;
  209. z-index: 10;
  210. .bg {
  211. position: absolute;
  212. left: 0;
  213. top: 0;
  214. width: 100vw;
  215. height: 60vw;
  216. opacity: 0.9;
  217. }
  218. .merchant {
  219. line-height: 1;
  220. width: 100%;
  221. display: flex;
  222. align-items: center;
  223. z-index: 12;
  224. font-weight: 500;
  225. font-size: $font-lg;
  226. padding: $spacing-sm $spacing-lg 14upx;
  227. .iconshouhuodizhi {
  228. font-size: 40upx;
  229. font-weight: 600;
  230. margin-right: $spacing-sm;
  231. }
  232. .iconxiajiantou1 {
  233. margin-left: 4upx;
  234. font-size: $font-base;
  235. }
  236. }
  237. .header {
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. z-index: 12;
  242. padding-bottom: 10upx;
  243. flex-direction: row;
  244. padding-left: 30upx;
  245. .addr {
  246. margin: 0 $spacing-base;
  247. height: 60upx;
  248. line-height: 60upx;
  249. padding-top: 6upx;
  250. .iconfont {
  251. font-weight: 500;
  252. font-size: 56upx;
  253. }
  254. .logo {
  255. width: 45upx;
  256. height: 45upx;
  257. border-radius: 8upx;
  258. margin-left: 10upx;
  259. }
  260. }
  261. .input-box {
  262. flex: 1;
  263. height: 60upx;
  264. line-height: 60upx;
  265. background-color: $color-white;
  266. border-radius: 30upx;
  267. position: relative;
  268. display: flex;
  269. align-items: center;
  270. margin: 6upx 0 0 $spacing-base;
  271. .wrapper,.wrapper2 {
  272. display: flex;
  273. align-items: center;
  274. position: absolute;
  275. top: 50%;
  276. left: 48%;
  277. font-size: $font-sm + 2upx;
  278. color: $font-color-light;
  279. transform: translate(-50%, -50%);
  280. flex-direction: row;
  281. .iconsousuo2 {
  282. font-size: 34upx;
  283. margin-right: $spacing-base;
  284. }
  285. }
  286. .wrapper2 {
  287. left: 40%;
  288. }
  289. input {
  290. width: 100%;
  291. padding-left: 28upx;
  292. height: 28upx;
  293. color: #888;
  294. font-size: 28upx;
  295. }
  296. }
  297. }
  298. }
  299. </style>