index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="container">
  3. <!-- 商家信息卡片 -->
  4. <view class="merchant-card">
  5. <view class="merchant-info">
  6. <image class="merchant-logo" :src="merchantInfo.merchantLogo" mode="aspectFill"></image>
  7. <view class="merchant-detail">
  8. <view class="merchant-name">{{merchantInfo.merchantName}}</view>
  9. </view>
  10. <view class="share-btn" @click="to_share">
  11. <image src="@/static/images/share.png" mode="aspectFit"></image>
  12. <text>分享店铺</text>
  13. </view>
  14. </view>
  15. <view class="merchant-phone">
  16. <image src="@/static/images/phone.png" mode="aspectFit"></image>
  17. <text>{{ merchantInfo.merchantPhone }}</text>
  18. </view>
  19. <!-- 商家描述 -->
  20. <view class="merchant-desc">
  21. <text>{{ merchantInfo.merchantDescribe }}</text>
  22. </view>
  23. </view>
  24. <!-- 联系商家部分 -->
  25. <view class="contact-section">
  26. <view class="section-title">联系商家</view>
  27. <!-- 二维码区域 -->
  28. <view class="qrcode-container">
  29. <image class="qrcode-img" :src="merchantInfo.merchantCodeUrl" mode="aspectFit"></image>
  30. <view class="qrcode-tip">扫码添加微信好友</view>
  31. </view>
  32. <!-- 客服按钮 -->
  33. <button class="service-btn" @click="onContactService">在线客服</button>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { ref } from 'vue';
  39. import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
  40. import {
  41. getSbmerchantInfo
  42. } from "@/api/merchant.js";
  43. import { toLogin } from "@/libs/login.js";
  44. import { useAppStore } from "@/stores/app.js";
  45. const appStore = useAppStore();
  46. const merchantInfo = ref('')
  47. const isLogin = appStore.isLogin;
  48. onLoad((options) => {
  49. getSbmerchantInfoFn();
  50. });
  51. const getSbmerchantInfoFn = () => {
  52. let data = {
  53. merchantId:2
  54. }
  55. getSbmerchantInfo(data).then((res) => {
  56. console.log(res);
  57. merchantInfo.value = res.data;
  58. })
  59. }
  60. // 分享功能
  61. const onShareAppMessage = () => {
  62. return {
  63. title: '水贝珠宝旗舰店',
  64. path: '/pages/merchant/detail?id=123'
  65. };
  66. };
  67. // 联系客服
  68. const onContactService = () => {
  69. // 实际项目中可调用uni.getCustomerServiceManager() API
  70. uni.showToast({
  71. title: '正在连接客服...',
  72. icon: 'loading'
  73. });
  74. };
  75. // 分享店铺
  76. const to_share = () => {
  77. if (isLogin) {
  78. uni.navigateTo({
  79. url: '/pages/users/share/index?merchantInfo='+encodeURIComponent(JSON.stringify(merchantInfo.value))
  80. });
  81. } else {
  82. toLogin();
  83. }
  84. }
  85. </script>
  86. <style scoped lang="scss">
  87. .container {
  88. padding: 30rpx;
  89. background-color: #f5f5f5;
  90. min-height: 100vh;
  91. box-sizing: border-box;
  92. }
  93. /* 头部样式 */
  94. .header {
  95. position: sticky;
  96. top: 0;
  97. display: flex;
  98. align-items: center;
  99. justify-content: space-between;
  100. height: 88rpx;
  101. padding: 0 32rpx;
  102. background-color: #fff;
  103. z-index: 100;
  104. }
  105. .back-icon, .more-icon {
  106. width: 48rpx;
  107. height: 48rpx;
  108. display: flex;
  109. align-items: center;
  110. image {
  111. width: 100%;
  112. height: 100%;
  113. }
  114. }
  115. .title {
  116. font-size: 36rpx;
  117. font-weight: bold;
  118. color: #000;
  119. }
  120. /* 商家卡片 */
  121. .merchant-card {
  122. padding: 20rpx;
  123. background-color: #fff;
  124. border-radius: 24rpx;
  125. position: relative;
  126. .merchant-info {
  127. display: flex;
  128. align-items: center;
  129. margin-bottom: 20rpx;
  130. .merchant-logo {
  131. width: 160rpx;
  132. height: 160rpx;
  133. border-radius: 8rpx;
  134. margin-right: 30rpx;
  135. }
  136. .merchant-detail {
  137. flex: 1;
  138. .merchant-name {
  139. font-size: 28rpx;
  140. font-weight: bold;
  141. color: #333;
  142. margin-bottom: 20rpx;
  143. }
  144. }
  145. .share-btn {
  146. position: absolute;
  147. top: 30rpx;
  148. right: 30rpx;
  149. display: flex;
  150. align-items: center;
  151. color: #666;
  152. font-size: 28rpx;
  153. image {
  154. width: 36rpx;
  155. height: 36rpx;
  156. margin-right: 10rpx;
  157. }
  158. }
  159. }
  160. .merchant-phone {
  161. display: flex;
  162. align-items: center;
  163. color: #666;
  164. font-size: 28rpx;
  165. margin-bottom: 20rpx;
  166. image {
  167. width: 36rpx;
  168. height: 36rpx;
  169. margin-right: 10rpx;
  170. }
  171. }
  172. .merchant-desc {
  173. width: 100%;
  174. padding: 30rpx;
  175. font-size: 28rpx;
  176. color: #333;
  177. background-color: #f9f9f9;
  178. border-radius: 20rpx;
  179. border: 2rpx solid #eee;
  180. margin-bottom: 20rpx;
  181. }
  182. }
  183. /* 联系商家部分 */
  184. .contact-section {
  185. margin-top: 30rpx;
  186. padding: 40rpx;
  187. background-color: #fff;
  188. border-radius: 24rpx;
  189. .section-title {
  190. font-size: 36rx;
  191. font-weight: bold;
  192. color: #333;
  193. margin-bottom: 40rpx;
  194. }
  195. .qrcode-container {
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. margin-bottom: 40rpx;
  200. .qrcode-img {
  201. width: 360rpx;
  202. height: 360rpx;
  203. }
  204. .qrcode-tip {
  205. margin-top: 20rpx;
  206. font-size: 28rpx;
  207. color: #666;
  208. }
  209. }
  210. .service-btn {
  211. width: 100%;
  212. height: 88rpx;
  213. line-height: 88rpx;
  214. background-color: #fff;
  215. color: #333;
  216. font-size: 32rpx;
  217. border: 2rpx solid #ddd;
  218. border-radius: 8rpx;
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. &:after {
  223. border: none;
  224. }
  225. }
  226. }
  227. </style>