index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view class="container">
  3. <!-- 商家信息卡片 -->
  4. <view class="store-card">
  5. <view class="info-top">
  6. <view class="left">
  7. <image class="storeImg" :src="merchantInfo.merchantLogo" mode="aspectFit"></image>
  8. </view>
  9. <view class="center">
  10. <view class="name">{{merchantInfo.merchantName}}</view>
  11. </view>
  12. <view class="right" @click="to_share">
  13. <image class="share" src="@/static/images/share.png" mode="widthFix"></image>
  14. <view>分享</view>
  15. </view>
  16. </view>
  17. <view class="desc">{{merchantInfo.merchantDescribe}}</view>
  18. <view class="tel" @click="makePhoneCall">
  19. <image class="phone mr20" src="@/static/images/phone2.png" mode="widthFix"></image>
  20. <text>联系电话:{{merchantInfo.merchantPhone}}</text>
  21. <image class="phone fr" src="@/static/images/phone.png" mode="widthFix"></image>
  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 { getQrcode } from "@/api/user.js"
  42. import { toLogin } from "@/libs/login.js";
  43. import { useAppStore } from "@/stores/app.js";
  44. import { HTTP_REQUEST_URL_IMG } from "@/config/app";
  45. const appStore = useAppStore();
  46. const merchantInfo = ref('')
  47. const isLogin = appStore.isLogin;
  48. onLoad(() => {
  49. if(appStore.merchantId || appStore.userInfo?.merchant?.id){
  50. let merchantId = appStore.merchantId || appStore.userInfo?.merchant?.id;
  51. getSbmerchantInfoFn(merchantId);
  52. }
  53. });
  54. const getSbmerchantInfoFn = async (merchantId) => {
  55. let data = {
  56. merchantId
  57. }
  58. const res = await getSbmerchantInfo(data);
  59. merchantInfo.value = res.data;
  60. if(!merchantInfo.value.merchantCodeUrl){
  61. const response = await getQrcode({id:merchantId})
  62. merchantInfo.value.merchantCodeUrl = response.message;
  63. }
  64. }
  65. // 分享功能
  66. const onShareAppMessage = () => {
  67. return {
  68. title: '水贝珠宝旗舰店',
  69. path: '/pages/merchant/detail?id=123'
  70. };
  71. };
  72. // 联系客服
  73. const onContactService = () => {
  74. // 实际项目中可调用uni.getCustomerServiceManager() API
  75. uni.showToast({
  76. title: '正在连接客服...',
  77. icon: 'loading'
  78. });
  79. };
  80. // 分享店铺
  81. const to_share = () => {
  82. if (isLogin) {
  83. uni.navigateTo({
  84. url: '/pages/users/share/index?merchantInfo='+encodeURIComponent(JSON.stringify(merchantInfo.value))
  85. });
  86. } else {
  87. toLogin();
  88. }
  89. }
  90. // 在methods部分添加:
  91. const makePhoneCall = () => {
  92. if (!merchantInfo.value.merchantPhone) {
  93. uni.showToast({
  94. title: '暂无联系电话',
  95. icon: 'none'
  96. });
  97. return;
  98. }
  99. // 显示确认弹窗
  100. uni.showModal({
  101. title: '拨打电话',
  102. content: `是否拨打 ${merchantInfo.value.merchantPhone}?`,
  103. success: (res) => {
  104. if (res.confirm) {
  105. // 调用拨打电话API
  106. uni.makePhoneCall({
  107. phoneNumber: merchantInfo.value.merchantPhone,
  108. success: () => {
  109. console.log('拨打电话成功');
  110. },
  111. fail: (err) => {
  112. console.log('拨打电话失败:', err);
  113. uni.showToast({
  114. title: '拨打电话失败',
  115. icon: 'none'
  116. });
  117. }
  118. });
  119. }
  120. }
  121. });
  122. };
  123. </script>
  124. <style scoped lang="scss">
  125. .container {
  126. padding: 30rpx;
  127. background-color: #f5f5f5;
  128. min-height: 100vh;
  129. box-sizing: border-box;
  130. }
  131. /* 头部样式 */
  132. .header {
  133. position: sticky;
  134. top: 0;
  135. display: flex;
  136. align-items: center;
  137. justify-content: space-between;
  138. height: 88rpx;
  139. padding: 0 32rpx;
  140. background-color: #fff;
  141. z-index: 100;
  142. }
  143. .back-icon, .more-icon {
  144. width: 48rpx;
  145. height: 48rpx;
  146. display: flex;
  147. align-items: center;
  148. image {
  149. width: 100%;
  150. height: 100%;
  151. }
  152. }
  153. .title {
  154. font-size: 36rpx;
  155. font-weight: bold;
  156. color: #000;
  157. }
  158. /* 商家卡片 */
  159. .store-card{
  160. background: #ffffff;
  161. border-radius: 16rpx;
  162. padding: 20rpx;
  163. margin-bottom: 10rpx;
  164. .info-top{
  165. display: flex;
  166. justify-content: space-around;
  167. align-items: center;
  168. background-color: #F9F7F0;
  169. border-radius: 16rpx;
  170. padding: 20rpx 0;
  171. .left{
  172. width: 140rpx;
  173. .storeImg{
  174. width: 100rpx;
  175. height: 100rpx;
  176. border-radius: 50%;
  177. }
  178. }
  179. .center{
  180. width: 50%;
  181. .name{
  182. font-size: 32rpx;
  183. color: #333;line-height: 60rpx;
  184. }
  185. }
  186. .right{
  187. width: 10%;
  188. font-size: 20rpx;
  189. color: #333;
  190. display: flex;
  191. flex-direction:column;
  192. justify-content: center;
  193. align-items: flex-end;
  194. .share{
  195. width: 40rpx;
  196. }
  197. }
  198. }
  199. .desc{
  200. font-size: 24rpx;
  201. color: #666;
  202. line-height: 40rpx;
  203. padding: 20rpx 0;
  204. }
  205. .tel{
  206. font-size: 28rpx;
  207. color:#333;
  208. line-height: 40rpx;
  209. .phone{
  210. width: 34rpx;
  211. vertical-align: middle;
  212. }
  213. }
  214. }
  215. /* 联系商家部分 */
  216. .contact-section {
  217. margin-top: 30rpx;
  218. padding: 40rpx;
  219. background-color: #fff;
  220. border-radius: 24rpx;
  221. .section-title {
  222. font-size: 36rx;
  223. font-weight: bold;
  224. color: #333;
  225. margin-bottom: 40rpx;
  226. }
  227. .qrcode-container {
  228. display: flex;
  229. flex-direction: column;
  230. align-items: center;
  231. margin-bottom: 40rpx;
  232. .qrcode-img {
  233. width: 360rpx;
  234. height: 360rpx;
  235. }
  236. .qrcode-tip {
  237. margin-top: 20rpx;
  238. font-size: 28rpx;
  239. color: #666;
  240. }
  241. }
  242. .service-btn {
  243. width: 100%;
  244. height: 88rpx;
  245. line-height: 88rpx;
  246. background-color: #fff;
  247. color: #333;
  248. font-size: 32rpx;
  249. border: 2rpx solid #ddd;
  250. border-radius: 8rpx;
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. &:after {
  255. border: none;
  256. }
  257. }
  258. }
  259. .fr{
  260. float: right;
  261. }
  262. </style>