index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. onLoad(async (options) => {
  51. id.value = options && options.id
  52. await searchConfig();
  53. await searchOther();
  54. await search();
  55. })
  56. // 查询其他信息
  57. const searchOther = async () => {
  58. let res;
  59. };
  60. // config信息
  61. const searchConfig = async () => {
  62. config.value = uni.getStorageSync('config');
  63. };
  64. // 查询
  65. const search = async () => {
  66. if (id.value) {
  67. const res = await $api(`car/${id.value}`, 'GET', {});
  68. if (res.errcode === 0) {
  69. if (res.data?.file?.length > 0) {
  70. res.data.file = res.data.file.map((item, index) => {
  71. return item.url
  72. })
  73. var one = res.data.file.slice(0, 9);
  74. var two = res.data.file.slice(9, 18);
  75. var thr = res.data.file.slice(18, 21);
  76. imageList.value = imageList.value.map((item, index) => {
  77. if (index == 0) item.url = one
  78. else if (index == 1) item.url = two
  79. else if (index == 2) item.url = thr
  80. return item
  81. })
  82. }
  83. } else {
  84. uni.showToast({
  85. title: res.errmsg || '',
  86. icon: 'error',
  87. });
  88. }
  89. }
  90. };
  91. // 联系卖家
  92. const toChat = (item) => {
  93. uni.makePhoneCall({
  94. phoneNumber: item.shop || '110',
  95. success: function () {
  96. console.log('拨打电话成功');
  97. },
  98. fail: function () {
  99. console.log('拨打电话失败');
  100. }
  101. });
  102. };
  103. // 点击切换
  104. const swichMenu = (index) => {
  105. if (index == current.value) return;
  106. current.value = index;
  107. itemId.value = `item${index}`
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .content {
  112. display: flex;
  113. flex-direction: column;
  114. width: 100vw;
  115. height: 100vh;
  116. color: var(--mainColor);
  117. background-color: var(--f00Color);
  118. .top {
  119. display: flex;
  120. padding: 2vw;
  121. .border {
  122. color: var(--fFFColor);
  123. }
  124. .text {
  125. padding: 2vw;
  126. font-size: var(--font16Size);
  127. font-weight: bold;
  128. }
  129. }
  130. .info {
  131. position: relative;
  132. flex-grow: 1;
  133. .one {
  134. padding: 2vw 4vw;
  135. .text {
  136. margin: 0 0 2vw 0;
  137. font-size: var(--font14Size);
  138. font-weight: bold;
  139. }
  140. .u-album {
  141. display: flex;
  142. flex-direction: column;
  143. align-items: center;
  144. }
  145. }
  146. }
  147. .foot {
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. height: 8vh;
  152. padding: 2vw 1vw;
  153. .foot_1 {
  154. display: flex;
  155. justify-content: space-between;
  156. width: 18%;
  157. .left {
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. color: var(--mainColor);
  162. font-size: var(--font14Size);
  163. }
  164. }
  165. .foot_2 {
  166. display: flex;
  167. justify-content: space-around;
  168. align-items: center;
  169. width: 85%;
  170. .left-btn {
  171. background-color: var(--fF0Color);
  172. color: var(--mainColor);
  173. font-size: var(--font16Size);
  174. }
  175. .right-btn {
  176. background-color: var(--fFFColor);
  177. color: var(--mainColor);
  178. width: 55vw;
  179. font-size: var(--font16Size);
  180. }
  181. }
  182. }
  183. }
  184. .scroll-view {
  185. position: absolute;
  186. top: 0;
  187. left: 0;
  188. right: 0;
  189. bottom: 0;
  190. .list-scroll-view {
  191. display: flex;
  192. flex-direction: column;
  193. }
  194. }
  195. </style>