pointsExchange.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <view class="content">
  3. <scroll-view scroll-y="true" style="height: 100%;">
  4. <empty v-if="integral.loaded === true && integral.list.length === 0"></empty>
  5. <view class="exchange-wrapper">
  6. <view class="exgood-wrapper" v-for="item in integral.list" :key="item.id" @click="navTo('/pages/product/product?id=' + item.id + '&type=2')">
  7. <image src="https://zccy.liuniu946.com/static/img/bg3.png" mode="" class="bg3"></image>
  8. <view class="ex-img-wrapper"><image :src="item.image" mode=""></image></view>
  9. <view class="exgood-title">{{item.title}}</view>
  10. <view class="ex-addr">
  11. <image src="../../static/img/shop.png" mode="" class="name-img"></image>
  12. {{checkedStore.name | storename}}
  13. <image src="../../static/img/point.png" mode="" class="point-img"></image>
  14. {{space(checkedStore.latitude, checkedStore.longitude) }}
  15. </view>
  16. <view class="ex-price">
  17. ¥{{item.price*1}}+{{item.integral*1}}
  18. <text class="tx1">积分</text>
  19. <text class="tx2">¥{{item.ot_price*1}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <uni-load-more :status="integral.loadingType"></uni-load-more>
  24. </scroll-view>
  25. </view>
  26. </template>
  27. <script>
  28. import empty from '@/components/empty';
  29. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  30. import { getCombinationList, getProductslist, getProductHot ,getIntegralList} from '@/api/product.js';
  31. import { mapMutations,mapState } from 'vuex';
  32. export default {
  33. components: {
  34. empty,
  35. uniLoadMore
  36. },
  37. data() {
  38. return {
  39. integral: {
  40. page: 1,
  41. limit: 10,
  42. list: [],
  43. loadingType: 'more',
  44. loaded: ''
  45. }
  46. }
  47. },
  48. computed: {
  49. ...mapState('user', ['userInfo', 'checkedStore', 'des', 'latlng']),
  50. },
  51. onLoad() {
  52. this.loadData()
  53. },
  54. onReachBottom() {
  55. this.loadData()
  56. },
  57. filters: {
  58. storename(val) {
  59. let str = ''
  60. if(val) {
  61. str = val
  62. if(val.length > 5) {
  63. str = val.slice(0,5)+'...'
  64. }
  65. }
  66. return str
  67. },
  68. longstorename(val) {
  69. let str = ''
  70. if(val) {
  71. str = val
  72. if(val.length > 10) {
  73. str = val.slice(0,10)+'...'
  74. }
  75. }
  76. return str
  77. }
  78. },
  79. methods:{
  80. space(lat1, lng1) {
  81. let sp = uni.getStorageSync('latlon');
  82. console.log(sp);
  83. let arr1 = sp.split(',');
  84. let lat2 = arr1[0];
  85. let lng2 = arr1[1];
  86. console.log(lat1, lng1, lat2, lng2, '位置信息');
  87. var radLat1 = (lat1 * Math.PI) / 180.0;
  88. var radLat2 = (lat2 * Math.PI) / 180.0;
  89. var a = radLat1 - radLat2;
  90. var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
  91. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  92. s = s * 6378.137;
  93. s = Math.round(s * 10000) / 10000;
  94. // return s * 1000;
  95. if (s > 1) {
  96. return s.toFixed(2) + 'km';
  97. } else {
  98. return s * 1000 + 'm'; // 单位米
  99. }
  100. },
  101. navTo(url) {
  102. uni.navigateTo({
  103. url: url
  104. })
  105. },
  106. loadData() {
  107. let obj = this
  108. if (obj.integral.loadingType === 'loading') {
  109. //防止重复加载
  110. return;
  111. }
  112. if (obj.integral.loadingType === 'noMore') {
  113. //防止重复加载
  114. return;
  115. }
  116. // 修改当前对象状态为加载中
  117. obj.integral.loadingType = 'loading';
  118. getIntegralList({
  119. page: obj.integral.page,
  120. limit: obj.integral.limit,
  121. }).then( ({data}) => {
  122. console.log(data)
  123. obj.integral.list = obj.integral.list.concat(data)
  124. console.log(obj.integral.list)
  125. if (obj.integral.limit == data.length) {
  126. //判断是否还有数据, 有改为 more, 没有改为noMore
  127. obj.integral.loadingType = 'more';
  128. return;
  129. } else {
  130. //判断是否还有数据, 有改为 more, 没有改为noMore
  131. obj.integral.loadingType = 'noMore';
  132. }
  133. uni.hideLoading();
  134. this.$set(obj.integral, 'loaded', true);
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. page {
  142. height: 100%;
  143. }
  144. .content {
  145. height: 100%;
  146. }
  147. .exchange-wrapper {
  148. // background-color: #fff;
  149. width: 696rpx;
  150. // height: 100rpx;
  151. padding-top: 28rpx;
  152. margin: 0 auto 39rpx;
  153. // padding: 0 27rpx;
  154. display: flex;
  155. justify-content: space-between;
  156. position: relative;
  157. flex-wrap: wrap;
  158. .exgood-wrapper {
  159. width: 342rpx;
  160. height: 540rpx;
  161. box-shadow: 0px 4px 18px 0px rgba(144, 27, 33, 0.13);
  162. margin-bottom: 20rpx;
  163. position: relative;
  164. .ex-img-wrapper {
  165. width: 342rpx;
  166. height: 338rpx;
  167. image {
  168. width: 100%;
  169. height: 100%;
  170. }
  171. }
  172. .exgood-title {
  173. margin-top: 33rpx;
  174. padding-left: 21rpx;
  175. font-size: 30rpx;
  176. font-weight: bold;
  177. color: #333333;
  178. white-space: nowrap;
  179. overflow: hidden;
  180. text-overflow: ellipsis;
  181. }
  182. .ex-addr {
  183. margin-top: 16rpx;
  184. padding-left: 22rpx;
  185. height: 22rpx;
  186. font-size: 22rpx;
  187. font-weight: 500;
  188. color: #dcb876;
  189. image {
  190. height: 22rpx;
  191. }
  192. .name-img {
  193. width: 26rpx;
  194. margin: 0 4rpx -3rpx 0;
  195. }
  196. .point-img {
  197. width: 16rpx;
  198. margin: 0 4rpx -3rpx 14rpx;
  199. }
  200. }
  201. .ex-price {
  202. margin-top: 17rpx;
  203. padding-left: 22rpx;
  204. font-size: 36rpx;
  205. font-weight: bold;
  206. color: #901b21;
  207. vertical-align: bottom;
  208. .tx1 {
  209. font-size: 24rpx;
  210. vertical-align: baseline;
  211. position: relative;
  212. top: -2rpx;
  213. }
  214. .tx2 {
  215. margin-left: 9rpx;
  216. font-size: 26rpx;
  217. font-weight: 500;
  218. text-decoration: line-through;
  219. color: #9d9d9d;
  220. line-height: 35rpx;
  221. }
  222. }
  223. .bg {
  224. position: absolute;
  225. top: 0;
  226. width: 342rpx;
  227. height: 540rpx;
  228. background-size: 100% 100%;
  229. }
  230. }
  231. }
  232. .bg3 {
  233. z-index: 3;
  234. width: 342rpx;
  235. height: 540rpx;
  236. position: absolute;
  237. top: 0;
  238. left: 0;
  239. }
  240. </style>