index.vue 6.6 KB

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