index.vue 5.2 KB

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