index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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/phoneyellow.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 { 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. // 在methods部分添加:
  85. const makePhoneCall = () => {
  86. if (!merchantInfo.value.merchantPhone) {
  87. uni.showToast({
  88. title: '暂无联系电话',
  89. icon: 'none'
  90. });
  91. return;
  92. }
  93. // 显示确认弹窗
  94. uni.showModal({
  95. title: '拨打电话',
  96. content: `是否拨打 ${merchantInfo.value.merchantPhone}?`,
  97. success: (res) => {
  98. if (res.confirm) {
  99. // 调用拨打电话API
  100. uni.makePhoneCall({
  101. phoneNumber: merchantInfo.value.merchantPhone,
  102. success: () => {
  103. console.log('拨打电话成功');
  104. },
  105. fail: (err) => {
  106. console.log('拨打电话失败:', err);
  107. uni.showToast({
  108. title: '拨打电话失败',
  109. icon: 'none'
  110. });
  111. }
  112. });
  113. }
  114. }
  115. });
  116. };
  117. </script>
  118. <style scoped lang="scss">
  119. .container {
  120. padding: 30rpx;
  121. background-color: #f5f5f5;
  122. min-height: 100vh;
  123. box-sizing: border-box;
  124. }
  125. /* 头部样式 */
  126. .header {
  127. position: sticky;
  128. top: 0;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. height: 88rpx;
  133. padding: 0 32rpx;
  134. background-color: #fff;
  135. z-index: 100;
  136. }
  137. .back-icon, .more-icon {
  138. width: 48rpx;
  139. height: 48rpx;
  140. display: flex;
  141. align-items: center;
  142. image {
  143. width: 100%;
  144. height: 100%;
  145. }
  146. }
  147. .title {
  148. font-size: 36rpx;
  149. font-weight: bold;
  150. color: #000;
  151. }
  152. /* 商家卡片 */
  153. .store-card{
  154. background: #ffffff;
  155. border-radius: 16rpx;
  156. padding: 20rpx;
  157. margin-bottom: 10rpx;
  158. .info-top{
  159. display: flex;
  160. justify-content: space-around;
  161. align-items: center;
  162. background-color: #F9F7F0;
  163. border-radius: 16rpx;
  164. .left{
  165. width: 140rpx;
  166. .storeImg{
  167. width: 100rpx;
  168. height: 100rpx;
  169. }
  170. }
  171. .center{
  172. width: 50%;
  173. .name{
  174. font-size: 32rpx;
  175. color: #333;line-height: 60rpx;
  176. }
  177. }
  178. .right{
  179. width: 10%;
  180. font-size: 20rpx;
  181. color: #333;
  182. display: flex;
  183. flex-direction:column;
  184. justify-content: center;
  185. align-items: flex-end;
  186. .share{
  187. width: 40rpx;
  188. }
  189. }
  190. }
  191. .desc{
  192. font-size: 24rpx;
  193. color: #666;
  194. line-height: 40rpx;
  195. padding: 20rpx 0;
  196. }
  197. .tel{
  198. font-size: 28rpx;
  199. color:#333;
  200. line-height: 40rpx;
  201. .phone{
  202. width: 34rpx;
  203. vertical-align: middle;
  204. }
  205. }
  206. }
  207. /* 联系商家部分 */
  208. .contact-section {
  209. margin-top: 30rpx;
  210. padding: 40rpx;
  211. background-color: #fff;
  212. border-radius: 24rpx;
  213. .section-title {
  214. font-size: 36rx;
  215. font-weight: bold;
  216. color: #333;
  217. margin-bottom: 40rpx;
  218. }
  219. .qrcode-container {
  220. display: flex;
  221. flex-direction: column;
  222. align-items: center;
  223. margin-bottom: 40rpx;
  224. .qrcode-img {
  225. width: 360rpx;
  226. height: 360rpx;
  227. }
  228. .qrcode-tip {
  229. margin-top: 20rpx;
  230. font-size: 28rpx;
  231. color: #666;
  232. }
  233. }
  234. .service-btn {
  235. width: 100%;
  236. height: 88rpx;
  237. line-height: 88rpx;
  238. background-color: #fff;
  239. color: #333;
  240. font-size: 32rpx;
  241. border: 2rpx solid #ddd;
  242. border-radius: 8rpx;
  243. display: flex;
  244. align-items: center;
  245. justify-content: center;
  246. &:after {
  247. border: none;
  248. }
  249. }
  250. }
  251. .fr{
  252. float: right;
  253. }
  254. </style>