merchantlist.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <div class="merchantlist">
  3. <div class="head">
  4. <div class="bg"></div>
  5. <div class="card">
  6. <div class="card_tit">消费积分账户</div>
  7. <div class="msg"><span>支持主流消费场所使用</span><span class="iconfont">&#xe631;</span></div>
  8. <div class="m">
  9. <div class="tit">账户余额</div>
  10. <div class="balance f_dinB">{{ local_uinfo.integral }}</div>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="list">
  15. <div class="li_item" v-for="(i,s) in merchantList" :key="s" @click="goMerchant(i)">
  16. <div class="logo_img">
  17. <img src="http://teaclub.oss-cn-chengdu.aliyuncs.com/CloudShop/head_pic/4820537f88796ee05a37530be80976921979f7f9png" alt="">
  18. </div>
  19. <div class="con_box">
  20. <div class="p1 ellipsis">{{ i.restaurant_name }}</div>
  21. <div class="p2">{{ i.restaurant_address }}</div>
  22. <div class="p3">{{ $h.Div(i.distance, 1000).toFixed(2) }} km</div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </template>
  28. <script>
  29. import QQMapWX from '@/static/utils/qqmap-wx-jssdk.min.js'
  30. import { post } from "@/request/api.js";
  31. export default {
  32. name: "merchantlist",
  33. props: {},
  34. components: {},
  35. data() {
  36. return {
  37. Query: {
  38. lat: 113.9367,
  39. lng: 22.5325,
  40. page: 1,
  41. rows: 20
  42. },
  43. merchant: {},
  44. merchantList: [],
  45. local_uinfo: {},
  46. };
  47. },
  48. methods: {
  49. // 获取附近商家
  50. getlists(){
  51. post("local/getMerchant",this.Query).then(res => {
  52. if(res.code == 0){
  53. let merchantList = res.data.data
  54. delete res.data.data
  55. this.merchant = res.data
  56. this.merchantList = [ ...this.merchantList, ...merchantList ]
  57. this.Query.page++
  58. }
  59. })
  60. },
  61. // 获取当前位置
  62. getLocation() {
  63. const that = this;
  64. // 获取位置信息
  65. uni.getLocation({
  66. type: 'wgs84',
  67. success(res) {
  68. // 经纬度转化地址信息
  69. // const qqmap = require('@/pages/qqmap-wx-jssdk.min.js');
  70. const showmap = new QQMapWX({
  71. key: 'NWSBZ-ZUME4-LLTU6-XSQGB-YBKAT-U4FCZ'
  72. });
  73. // 逆地址解析reverseGeocoder
  74. showmap.reverseGeocoder({
  75. location: {
  76. latitude: res.latitude,
  77. longitude: res.longitude
  78. },
  79. success(result) {
  80. const adres = result.result.location;
  81. that.Query = { ...that.Query, ...adres };
  82. that.getlists();
  83. }
  84. });
  85. },
  86. fail(e) {
  87. let errMsgTit = '';
  88. if (e.errMsg === 'getLocation:fail auth deny') {
  89. errMsgTit = '你已拒绝授权,是否跳转至设置页面开启权限';
  90. } else {
  91. errMsgTit = '操作频繁提示,建议搭配onLocationChange()使用';
  92. }
  93. uni.showModal({
  94. title: '提示',
  95. content: `${errMsgTit}`,
  96. success(res) {
  97. if (res.confirm) {
  98. // 获取设置页面权限信息
  99. uni.getSetting({
  100. success(res) {
  101. console.log(res.authSetting);
  102. // 判断是否开启获取位置权限
  103. if (!res.authSetting['scope.userLocation']) {
  104. // 如果没有开启,点击确认后打开设置页面
  105. uni.openSetting({});
  106. }
  107. }
  108. });
  109. console.log('用户点击确定');
  110. } else if (res.cancel) {
  111. console.log('用户点击取消');
  112. }
  113. }
  114. });
  115. }
  116. });
  117. },
  118. // 去店铺
  119. goMerchant(da) {
  120. uni.setStorageSync("MerchantItem",da)
  121. this.goto("/pagesB/orderingfood/orderingfood",{
  122. brand_id:da.brand_id,
  123. restaurant_id:da.restaurant_id
  124. })
  125. },
  126. // 是否激活本地生活
  127. isActivation(){
  128. post("local/isActivation",this.Query).then(res => {
  129. if(res.code == -1){
  130. this.goto("/pagesB/orderingfood/activation")
  131. }else{
  132. this.getLocation();
  133. this.getLU();
  134. }
  135. })
  136. },
  137. getLU(){
  138. post("local/userinfo").then(res=>{
  139. if(res.code == 0){
  140. this.local_uinfo = res.data
  141. }
  142. })
  143. }
  144. },
  145. onShow() {
  146. this.isActivation();
  147. },
  148. mounted() {},
  149. onReachBottom() {
  150. if(this.Query.page < this.merchant.last_page) this.getlists();
  151. },
  152. };
  153. </script>
  154. <style scoped lang='scss'>
  155. .head{
  156. .bg{
  157. height: 300rpx;
  158. background-image: url("http://teaclub.oss-cn-chengdu.aliyuncs.com/CloudShop/head_pic/a5500a3c12f967a83d123f774b333e2b2d9729bcpng");
  159. background-size: 100% 100%;
  160. }
  161. .card{
  162. width: calc(100% - 60rpx);
  163. margin: -110rpx 30rpx 0;
  164. background-color: #473D31;
  165. // background: url("~@/static/my/myBack.png") no-repeat;
  166. // background-size: 100% 100%;
  167. border-radius: 16rpx;
  168. padding: 28rpx 30rpx;
  169. height: 280rpx;
  170. position: relative;
  171. .card_tit{
  172. font-size: 36rpx;
  173. color: #C99D60;
  174. }
  175. .msg{
  176. color: #C99D60;
  177. font-size: 20rpx;
  178. margin-top: 8rpx;
  179. .iconfont{
  180. color: #C99D60;
  181. font-size: 28rpx;
  182. margin-left: 6rpx;
  183. }
  184. span{
  185. vertical-align: middle;
  186. }
  187. }
  188. .m{
  189. position: absolute;
  190. bottom: 30rpx;
  191. right: 30rpx;
  192. }
  193. .tit,.balance{
  194. color: #C99D60;
  195. text-align: right;
  196. }
  197. .balance{
  198. font-size: 40rpx;
  199. margin-top: 8rpx;
  200. &:before {
  201. content: "¥";
  202. font-size: 24rpx;
  203. }
  204. }
  205. }
  206. }
  207. .list{
  208. padding: 30rpx;
  209. .li_item{
  210. margin-bottom: 20rpx;
  211. padding: 28rpx 32rpx;
  212. background-color: #fff;
  213. border-radius: 10rpx;
  214. box-shadow: 4rpx 4rpx 26rpx 2rpx rgba(17, 18, 29, 0.1);
  215. }
  216. .logo_img,.con_box{
  217. display: inline-block;
  218. vertical-align: top;
  219. }
  220. .logo_img{
  221. img{
  222. height: 180rpx;
  223. width: 180rpx;
  224. border-radius: 10rpx;
  225. }
  226. }
  227. .con_box{
  228. height: 180rpx;
  229. width: calc(100% - 180rpx - 28rpx);
  230. margin-left: 28rpx;
  231. position: relative;
  232. .p1{
  233. font-size: 32rpx;
  234. font-weight: bold;
  235. color: #333;
  236. margin-bottom: 6rpx;
  237. }
  238. .p2{
  239. font-size: 24rpx;
  240. color: #999;
  241. }
  242. .p3{
  243. font-size: 24rpx;
  244. color: #666;
  245. position: absolute;
  246. right: 0;
  247. bottom: 0;
  248. }
  249. }
  250. }
  251. </style>