耀实惠小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
4.6 KiB

  1. <template>
  2. <view class="receiving flex-1">
  3. <view class="receiving-container" v-if="addressData.length">
  4. <view v-for="item in addressData" :key="item.id">
  5. <receiving-item :list="item" active :type="type" />
  6. </view>
  7. </view>
  8. <view class="vw-100 h-100" v-else>
  9. <u-empty icon-size="430" mode="" :src="IMG_URL + 'receiving-empty.png'"></u-empty>
  10. </view>
  11. <view class="receiving-footer position-fixed flex align-center justify-center" v-if="!addressData.length">
  12. <u-button type="primary" shape="circle" @click="toAdd">新增取货点</u-button>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { IMG_URL } from '@/env.js'
  18. export default{
  19. data(){
  20. return{
  21. IMG_URL,
  22. value:'',
  23. params:{
  24. pageNo:1,
  25. pageSize:10
  26. },
  27. addressData:[],
  28. pageNo: 1,
  29. pageSize: 10,
  30. total: null,
  31. isLock: true,
  32. type: ''
  33. }
  34. },
  35. computed: {
  36. userInfo () {
  37. return this.$store.state.userInfo
  38. },
  39. longitude () {
  40. console.log(this.userInfo)
  41. return this.userInfo?.longitude || 0
  42. },
  43. latitude () {
  44. return this.userInfo?.latitude || 0
  45. }
  46. },
  47. onLoad(options) {
  48. this.type = options?.type || ''
  49. this.getStationmasterList()
  50. // this.getLongitudeLatitude();
  51. uni.$on('delAddress', () => {
  52. })
  53. },
  54. onUnload() {
  55. uni.$off('delAddress');
  56. },
  57. onReachBottom() {
  58. if(this.isLock) {
  59. if(this.total !== null && this.pageNo * this.pageSize >= this.total){
  60. this.isLock = false;
  61. this.$Toast('没有更多数据了哦!');
  62. setTimeout(()=>{
  63. this.isLock = true;
  64. },3000)
  65. return
  66. }
  67. this.pageNo+=1;
  68. this.getStationmasterList();
  69. }
  70. },
  71. methods: {
  72. toAdd () {
  73. this.$tools.navigateTo({
  74. url: '/pagesC/receiving/receivingMap'
  75. })
  76. },
  77. getStationmasterList(){
  78. const params = {
  79. longitude: this.longitude,
  80. latitude: this.latitude
  81. }
  82. this.$api('getStationmasterList',params).then( res => {
  83. let { code, result, message } = res;
  84. if( code == 200) {
  85. result.forEach(item => {
  86. item.distance = this.GetDistance(item.latitude,item.longitude);
  87. })
  88. this.addressData = this.addressData.concat(result);
  89. console.log(this.addressData)
  90. } else {
  91. code !== 9001 && this.$Toast(message)
  92. }
  93. }).catch(err => {
  94. this.$Toast(err.message)
  95. })
  96. },
  97. Rad(d) {
  98. return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。
  99. },
  100. GetDistance(lat1, lng1) {//传入两个点的经纬度
  101. let lat2= this.latitude;
  102. let lng2 = this.longitude;
  103. let radLat1 = this.Rad(lat1);
  104. let radLat2 = this.Rad(lat2);
  105. let a = radLat1 - radLat2;
  106. let b = this.Rad(lng1) - this.Rad(lng2);
  107. let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  108. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  109. s = s * 6378.137;// EARTH_RADIUS;
  110. s = Math.round(s * 10000) / 10000; //输出为公里
  111. s = s.toFixed(2);//保留小数点后两位小数
  112. return s;
  113. },
  114. }
  115. }
  116. </script>
  117. <style scoped lang="scss">
  118. .list-box{
  119. width: 750upx;
  120. }
  121. .u-radio-group{
  122. width: 100%;
  123. }
  124. .item{
  125. margin: 32upx;
  126. border: 1upx solid #707070;
  127. padding: 20upx;
  128. border-radius: 10upx;
  129. position: relative;
  130. width: 100%;
  131. .delete{
  132. position: absolute;
  133. right: 20upx;
  134. top: 20upx;
  135. }
  136. .header-box{
  137. display: flex;
  138. align-items: center;
  139. text{
  140. margin-left: 12upx;
  141. font-size: 26upx;
  142. }
  143. .phone-box{
  144. margin-left: 20upx;
  145. }
  146. .nickname{
  147. font-size: 28upx;
  148. font-weight: bold;
  149. color: #000000;
  150. }
  151. .tel{
  152. color: #707070;
  153. margin-left: 4upx;
  154. }
  155. }
  156. .content-box{
  157. padding: 20upx 10upx;
  158. display: flex;
  159. font-size: 28upx;
  160. color: #707070;
  161. text{
  162. margin-left: 8upx;
  163. }
  164. }
  165. .bottom-box{
  166. padding:10upx 10upx 10upx 10upx;
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. font-size: 26upx;
  171. .text-orange-dark{
  172. color: #FFA206;
  173. font-size: 26upx;
  174. }
  175. }
  176. }
  177. .function-box{
  178. position: fixed;
  179. bottom: 0upx;
  180. left: 0upx;
  181. height: 150upx;
  182. width: 750upx;
  183. display: flex;
  184. align-items: center;
  185. justify-content: center;
  186. .create{
  187. display: flex;
  188. align-items: center;
  189. justify-content: center;
  190. width: 670upx;
  191. height: 95upx;
  192. background-color: #000000;
  193. color: #FFFFFF;
  194. }
  195. }
  196. .receiving {
  197. padding-bottom: 120rpx;
  198. &-container {
  199. height: 100%;
  200. background: #fff;
  201. padding: 30rpx;
  202. }
  203. &-footer {
  204. height: 120rpx;
  205. bottom: 0;
  206. left: 0;
  207. width: 100%;
  208. background: #fff;
  209. /deep/.u-btn {
  210. width: 600rpx;
  211. height: 80rpx;
  212. }
  213. }
  214. }
  215. </style>