index.vue 5.1 KB

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