indexMsg.vue 7.6 KB

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