merchant.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="hotel">
  3. <navcustom :config="config" class="navcustom" v-if="customShow"/>
  4. <div class="head_img" @click="onpreview(0)">
  5. <image :src="detail.atlas[0]" mode="aspectFill" class="bg_img" />
  6. </div>
  7. <div class="head_info">
  8. <div class="head_info_row flex_r flex_ac">
  9. <image class="logo" :src="detail.logo"/>
  10. <div class="head_name">
  11. <div class="name">{{ detail.name }}</div>
  12. <div class="flex_r flex_ac">
  13. <uni-rate :max="5" :value="detail.score" :size="12" allow-half />
  14. <span class="commentScore">{{detail.score}}分</span>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="h_address flex_r flex_jb flex_ac">
  19. <div class="hil">
  20. <div class="h_tags flex_r flex_ac flex_wrap">
  21. <span class="tag">距您 {{ $h.Div(Number(detail.distance), 1000).toFixed(2) || 0 }} km</span>
  22. </div>
  23. <div class="address">{{ detail.address }}</div>
  24. </div>
  25. <div class="iconfont ico" @click="openm">&#xe6b3;</div>
  26. </div>
  27. <div class="summary" v-if="detail.summary">
  28. <div class="tit">店铺介绍</div>
  29. <div class="txt ellipsis3">{{detail.summary}}</div>
  30. </div>
  31. <div class="atlas_list">
  32. <image v-for="(i,s) in detail.atlas" :key="s" :src="i" @click="onpreview(s)" mode="aspectFill" class="atlas_img" />
  33. </div>
  34. </div>
  35. <div class="btn-box">
  36. <div class="btn" @click="topay">快捷买单</div>
  37. </div>
  38. <!-- 图片查看组件 -->
  39. <preview ref="previewimg" :listType="2" @close="previewclose"/>
  40. <!-- 授权 -->
  41. <!-- <authorize-module ref="autho" :shopInfo="shopInfo" @authGetTelSuccess="onauthGetTelSuccess" /> -->
  42. </div>
  43. </template>
  44. <script>
  45. let app = getApp();
  46. import preview from "@/components/swiper-preview/index";
  47. import navcustom from "@/components/navigationCustom/navigation-custom.vue"
  48. import authorizeModule from "@/components/authorize-module/index";
  49. import { post } from "@/request/api.js";
  50. export default {
  51. name: "hotel",
  52. props: {},
  53. components: { preview, navcustom, authorizeModule },
  54. data() {
  55. return {
  56. query: {},
  57. shopID: "",
  58. detail: {},
  59. config: {
  60. title: "",
  61. bgcolor: "",
  62. type: 1,
  63. linear: false,
  64. transparent: true,
  65. fontcolor: "#000",
  66. menuIcon: "",
  67. menuText: ""
  68. },
  69. customShow: true,
  70. shopInfo: {}, // 商铺信息
  71. unid: "",
  72. };
  73. },
  74. methods: {
  75. async merchant(){
  76. uni.showLoading({ title: '加载中',mask: true });
  77. let adres = await uni.Location();
  78. post("v1/merchant/detail", {
  79. shop_id: this.shopID,
  80. longitude: adres.lng,
  81. latitude: adres.lat
  82. }).then((res) => {
  83. uni.hideLoading();
  84. if (res.code == 0) {
  85. let da = res.data;
  86. if(da.atlas) da.atlas = JSON.parse(da.atlas)
  87. else da.atlas = []
  88. this.detail = da
  89. }
  90. });
  91. },
  92. onpreview(current) {
  93. if (this.detail.atlas.length) {
  94. this.customShow = false
  95. this.$refs.previewimg.open({
  96. imgs: this.detail.atlas,
  97. current,
  98. });
  99. }
  100. },
  101. previewclose(){
  102. this.customShow = true
  103. },
  104. openm() {
  105. let { name, address, latitude, longitude } = this.detail
  106. uni.openLocation({
  107. latitude: Number(latitude), longitude: Number(longitude), scale: 18, name, address,
  108. success: function() {
  109. console.log('success');
  110. }
  111. });
  112. },
  113. topay(){
  114. this.setLS("topay_merchant",this.detail)
  115. this.goto("/pagesC/settledMerchant/pay")
  116. },
  117. // SoHAuth() {
  118. // this.$refs.autho.onSoHAuth();
  119. // },
  120. login(invite) {
  121. const deviceInfo = wx.getDeviceInfo()
  122. let that = this;
  123. // #ifdef MP-WEIXIN
  124. wx.login({
  125. success(res) {
  126. if (res.code) {
  127. post("v1/appletLogin", {
  128. code: res.code,
  129. phone_model: deviceInfo.model,//设备型号
  130. phone_brand: deviceInfo.brand,//设备品牌
  131. invite: uni.getStorageSync("inviteCode") || ""
  132. }).then((res) => {
  133. if (res.code === 0) {
  134. if (res.data.token) {
  135. uni.setStorageSync("token", res.data.token);
  136. that.merchant();
  137. } else {
  138. that.unid = res.data.unid;
  139. uni.setStorageSync("unid", res.data.unid);
  140. that.shopInfo = app.globalData.shopInfo;
  141. // that.SoHAuth(); //调取授权弹窗
  142. }
  143. }
  144. });
  145. }
  146. },
  147. });
  148. // #endif
  149. },
  150. // onauthGetTelSuccess(da) {
  151. // this.SoHAuth();
  152. // post("v1/getMobile", {
  153. // unid: this.unid,
  154. // ...da.detail,
  155. // }).then((res) => {
  156. // if (res.code === 0) {
  157. // uni.setStorageSync("token", res.data.token);
  158. // this.merchant();
  159. // }
  160. // });
  161. // },
  162. sceneToObject(scene) {
  163. scene = decodeURIComponent(scene);
  164. let ret = {}
  165. let regParam = /([^&=]+)=([\w\W]*?)(&|$|#)/g
  166. let strParam = scene;
  167. let result
  168. while ((result = regParam.exec(strParam)) != null) {
  169. ret[result[1]] = result[2]
  170. }
  171. return ret;
  172. },
  173. },
  174. onLoad(da) {
  175. console.log("参数:", da);
  176. if(da.scene) da = this.sceneToObject(da.scene);
  177. console.log("参数:", da);
  178. this.shopID = da.id;
  179. let token = uni.getStorageSync("token");
  180. if (!token) this.login();
  181. else this.merchant();
  182. },
  183. onShow() {},
  184. mounted() {},
  185. };
  186. </script>
  187. <style scoped lang='scss'>
  188. .navcustom{
  189. position: absolute;
  190. left: 0;
  191. top: 0;
  192. }
  193. .head_img {
  194. .bg_img {
  195. width: 100%;
  196. height: 460rpx;
  197. }
  198. }
  199. .head_info {
  200. padding: 30rpx;
  201. .head_info_row{
  202. .logo{
  203. width: 120rpx;
  204. height: 110rpx;
  205. border-radius: 12rpx;
  206. margin-right: 25rpx;
  207. }
  208. .head_name {
  209. .name{
  210. font-size: 36rpx;
  211. font-weight: 600;
  212. margin-bottom: 12rpx;
  213. }
  214. .commentScore {
  215. margin-left: 10rpx;
  216. font-size: 24rpx;
  217. }
  218. }
  219. }
  220. .h_tags {
  221. font-size: 25rpx;
  222. font-weight: 400;
  223. margin-bottom: 6rpx;
  224. span {
  225. margin-right: 18rpx;
  226. &:last-child {
  227. margin-right: 0;
  228. }
  229. }
  230. }
  231. .h_address {
  232. padding: 20rpx 0;
  233. margin-bottom: 26rpx;
  234. .address {
  235. font-size: 24rpx;
  236. }
  237. .hil{
  238. width: calc(100% - 100rpx);
  239. }
  240. .ico {
  241. width: 60rpx;
  242. height: 50rpx;
  243. text-align: center;
  244. line-height: 50rpx;
  245. font-size: 50rpx;
  246. }
  247. }
  248. .summary{
  249. font-size: 26rpx;
  250. color: #666;
  251. margin-bottom: 18rpx;
  252. .tit {
  253. height: 30rpx;
  254. line-height: 30rpx;
  255. font-size: 30rpx;
  256. margin-bottom: 18rpx;
  257. padding-left: 12rpx;
  258. border-left: 6rpx solid #00A238;
  259. }
  260. }
  261. }
  262. .atlas_list{
  263. max-height: 334rpx;
  264. overflow: hidden;
  265. display: grid;
  266. justify-content: space-between;
  267. grid-template-columns: repeat(auto-fill, 220rpx);
  268. grid-gap: 14rpx 0;
  269. .atlas_img{
  270. width: 220rpx;
  271. height: 160rpx;
  272. border-radius: 12rpx;
  273. }
  274. }
  275. .btn-box{
  276. padding: 0 30rpx;
  277. .btn{
  278. // display: inline-block;
  279. color: #fff;
  280. background: #00A238;
  281. font-size: 36rpx;
  282. font-weight: 600;
  283. height: 80rpx;
  284. line-height: 80rpx;
  285. text-align: center;
  286. // padding: 6rpx 30rpx;
  287. border-radius: 46rpx;
  288. margin-top: 50rpx;
  289. }
  290. }
  291. </style>