index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <view v-for="(item,index) in imageList" :key="index" @tap="swichMenu(index)">
  5. <text :class="[current == index ? 'border' : '']"
  6. class="text">{{item.name}}({{item?.url?.length||0}})</text>
  7. </view>
  8. </view>
  9. <view class="info">
  10. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" :scroll-into-view="itemId">
  11. <view class="list-scroll-view">
  12. <view class="one" v-for="(item,index) in imageList" :key="index">
  13. <view class="text" :id="'item' + index">{{item.name}}({{item?.url?.length||0}})</view>
  14. <u-album :urls="item.url" @albumWidth="width => albumWidth = width"
  15. multipleSize="110"></u-album>
  16. </view>
  17. </view>
  18. </scroll-view>
  19. </view>
  20. <view class="foot">
  21. <view class="foot_1">
  22. <view class="left" @click="toChat">
  23. <u-icon color="#ffffff" name="red-packet" size="20"></u-icon>
  24. <text>分期购车</text>
  25. </view>
  26. </view>
  27. <view class="foot_2">
  28. <button class="left-btn" @click="toChat">联系卖家</button>
  29. <button class="right-btn" @click="toChat">询底价</button>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script setup lang="ts">
  35. import { getCurrentInstance, computed, ref } from 'vue';
  36. //该依赖已内置不需要单独安装
  37. import { onLoad } from "@dcloudio/uni-app";
  38. // 请求接口
  39. const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
  40. // openid
  41. const openid = computed(() => {
  42. return uni.getStorageSync('openid');
  43. })
  44. // 基本信息
  45. const config = ref({});
  46. const id = ref('');
  47. const current = ref(0);
  48. const itemId = ref(''); // 栏目右边scroll-view用于滚动的id
  49. const imageList = ref([{ name: '外观', url: [] }, { name: '内饰', url: [] }, { name: '空间', url: [] }]);
  50. // 店铺
  51. const shop = ref({});
  52. onLoad(async (options) => {
  53. id.value = options && options.id
  54. const shopId = options && options.shop
  55. await searchConfig();
  56. await searchOther(shopId);
  57. await search();
  58. })
  59. // 查询其他信息
  60. const searchOther = async (id) => {
  61. let res;
  62. res = await $api(`shop/${id}`, 'GET', {});
  63. if (res.errcode === 0) {
  64. shop.value = res.data
  65. } else {
  66. uni.showToast({
  67. title: res.errmsg || '',
  68. icon: 'error',
  69. });
  70. }
  71. };
  72. // config信息
  73. const searchConfig = async () => {
  74. config.value = uni.getStorageSync('config');
  75. };
  76. // 查询
  77. const search = async () => {
  78. if (id.value) {
  79. const res = await $api(`car/${id.value}`, 'GET', {});
  80. if (res.errcode === 0) {
  81. if (res.data?.file?.length > 0) {
  82. res.data.file = res.data.file.map((item, index) => {
  83. return item.url
  84. })
  85. var one = res.data.file.slice(0, 9);
  86. var two = res.data.file.slice(9, 18);
  87. var thr = res.data.file.slice(18, 21);
  88. imageList.value = imageList.value.map((item, index) => {
  89. if (index == 0) item.url = one
  90. else if (index == 1) item.url = two
  91. else if (index == 2) item.url = thr
  92. return item
  93. })
  94. }
  95. } else {
  96. uni.showToast({
  97. title: res.errmsg || '',
  98. icon: 'error',
  99. });
  100. }
  101. }
  102. };
  103. // 联系卖家
  104. const toChat = () => {
  105. uni.makePhoneCall({
  106. phoneNumber: shop.value?.tel,
  107. success: function () {
  108. console.log('拨打电话成功');
  109. },
  110. fail: function () {
  111. uni.showToast({
  112. title: '拨打电话失败',
  113. icon: 'error',
  114. });
  115. }
  116. });
  117. };
  118. // 点击切换
  119. const swichMenu = (index) => {
  120. if (index == current.value) return;
  121. current.value = index;
  122. itemId.value = `item${index}`
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .content {
  127. display: flex;
  128. flex-direction: column;
  129. width: 100vw;
  130. height: 100vh;
  131. color: var(--mainColor);
  132. background-color: var(--f00Color);
  133. .top {
  134. display: flex;
  135. padding: 2vw;
  136. .border {
  137. color: var(--fFFColor);
  138. }
  139. .text {
  140. padding: 2vw;
  141. font-size: var(--font16Size);
  142. font-weight: bold;
  143. }
  144. }
  145. .info {
  146. position: relative;
  147. flex-grow: 1;
  148. .one {
  149. padding: 2vw 4vw;
  150. .text {
  151. margin: 0 0 2vw 0;
  152. font-size: var(--font14Size);
  153. font-weight: bold;
  154. }
  155. .u-album {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. }
  160. }
  161. }
  162. .foot {
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. height: 8vh;
  167. padding: 2vw 1vw;
  168. .foot_1 {
  169. display: flex;
  170. justify-content: space-between;
  171. width: 18%;
  172. .left {
  173. display: flex;
  174. flex-direction: column;
  175. align-items: center;
  176. color: var(--mainColor);
  177. font-size: var(--font14Size);
  178. }
  179. }
  180. .foot_2 {
  181. display: flex;
  182. justify-content: space-around;
  183. align-items: center;
  184. width: 85%;
  185. .left-btn {
  186. background-color: var(--fF0Color);
  187. color: var(--mainColor);
  188. font-size: var(--font16Size);
  189. }
  190. .right-btn {
  191. background-color: var(--fFFColor);
  192. color: var(--mainColor);
  193. width: 55vw;
  194. font-size: var(--font16Size);
  195. }
  196. }
  197. }
  198. }
  199. .scroll-view {
  200. position: absolute;
  201. top: 0;
  202. left: 0;
  203. right: 0;
  204. bottom: 0;
  205. .list-scroll-view {
  206. display: flex;
  207. flex-direction: column;
  208. }
  209. }
  210. </style>