captain.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <app-layout>
  3. <view v-if="list.length > 0">
  4. <view @click="bind(item)" class="dir-left-nowrap cross-center captain" v-for="item in list" :key="item.id">
  5. <image class="avatar" :src="item.avatar"></image>
  6. <view class="user dir-top-nowrap main-center">
  7. <view class="name t-omit">
  8. <text>{{item.name}}</text>
  9. <view class="space" :class="getTheme + '-m-text ' + getTheme">距你{{item.space}}</view>
  10. </view>
  11. <view class="t-omit">{{item.mobile}}</view>
  12. <view class="address t-omit-two">
  13. <view>
  14. <image class="icon" src="./../image/add.png"></image>
  15. 提货地址:{{item.province}}
  16. <text v-if="item.province != item.city">{{item.city}}</text>{{item.district}}{{item.detail}}
  17. </view>
  18. </view>
  19. </view>
  20. <image class="arrow-image" src="/static/image/icon/right.png"></image>
  21. </view>
  22. </view>
  23. <view v-if="list.length == 0 && !loading" class="empty-box">
  24. <image src="./../image/no-one.png"></image>
  25. <span>暂无团长</span>
  26. </view>
  27. </app-layout>
  28. </template>
  29. <script>
  30. import {mapGetters, mapState} from 'vuex';
  31. export default {
  32. data() {
  33. return {
  34. longitude: '',
  35. latitude: '',
  36. list: [],
  37. loading: false,
  38. page: 1,
  39. }
  40. },
  41. computed: {
  42. ...mapGetters('mallConfig', {
  43. getTheme: 'getTheme',
  44. }),
  45. ...mapState({
  46. stock: state => state.mallConfig.__wxapp_img.stock,
  47. bonusImg: state => state.mallConfig.__wxapp_img.bonus,
  48. userInfo: state => state.user.info,
  49. })
  50. },
  51. onLoad: function (options) {
  52. this.longitude = options.longitude;
  53. this.latitude = options.latitude;
  54. this.getList();
  55. },
  56. methods: {
  57. bind(item) {
  58. let that = this;
  59. uni.showLoading({
  60. title: '绑定中...'
  61. });
  62. that.$request({
  63. url: that.$api.community.bind,
  64. data: {
  65. middleman_id: item.user_id
  66. }
  67. }).then(response=>{
  68. uni.hideLoading();
  69. uni.removeStorage({
  70. key: 'middleman_info'
  71. });
  72. if(response.data.is_private) {
  73. uni.showToast({
  74. title: '切换成功',
  75. icon: 'none',
  76. duration: 1000
  77. });
  78. item.is_allow_change = 1;
  79. uni.setStorage({
  80. key: 'middleman_info',
  81. data: item
  82. })
  83. }else {
  84. uni.showToast({
  85. title: response.msg,
  86. icon: 'none',
  87. duration: 1000
  88. });
  89. }
  90. if(response.code == 0) {
  91. uni.setStorage({
  92. key: 'bind',
  93. data: item.user_id,
  94. success: function () {
  95. setTimeout(function(){
  96. uni.navigateBack({});
  97. },1000)
  98. },
  99. fail() {
  100. setTimeout(function(){
  101. uni.navigateBack({});
  102. },1000)
  103. }
  104. });
  105. }
  106. }).catch(response => {
  107. that.$hideLoading();
  108. });
  109. },
  110. getList() {
  111. let that = this;
  112. that.loading = true;
  113. that.$showLoading({
  114. type: 'global',
  115. text: '加载中...'
  116. });
  117. that.$request({
  118. url: that.$api.community.middleman_list,
  119. data: {
  120. longitude: this.longitude,
  121. latitude: this.latitude,
  122. page: this.page,
  123. }
  124. }).then(response=>{
  125. that.$hideLoading();
  126. that.loading = false;
  127. if(response.code == 0) {
  128. that.list = response.data.list;
  129. for(let i in that.list) {
  130. that.list[i].space = ~~that.list[i].distance +'m';
  131. if(that.list[i].distance > 1000) {
  132. that.list[i].space = (that.list[i].distance / 1000).toFixed(1) + 'km'
  133. }
  134. }
  135. }else {
  136. uni.showToast({
  137. title: response.msg,
  138. icon: 'none',
  139. duration: 1000
  140. });
  141. }
  142. }).catch(response => {
  143. that.loading = false;
  144. that.$hideLoading();
  145. });
  146. },
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .captain {
  152. width: #{698rpx};
  153. height: #{192rpx};
  154. border-radius: #{16rpx};
  155. padding: 0 #{32rpx};
  156. margin: #{20rpx} #{28rpx} 0;
  157. background-color: #fff;
  158. .avatar {
  159. width: #{84rpx};
  160. height: #{84rpx};
  161. border-radius: 50%;
  162. margin-right: #{18rpx};
  163. flex-shrink: 0;
  164. }
  165. .user {
  166. width: #{495rpx};
  167. height: #{150rpx};
  168. color: #353535;
  169. font-size: #{26rpx};
  170. .name {
  171. font-size: #{30rpx};
  172. font-weight: 600;
  173. margin-bottom: #{10rpx};
  174. position: relative;
  175. .space {
  176. position: absolute;
  177. top: 0;
  178. right: 0;
  179. height: #{40rpx};
  180. font-size: #{26rpx};
  181. line-height: #{40rpx};
  182. font-weight: 400;
  183. }
  184. }
  185. .address {
  186. width: #{504rpx};
  187. .icon {
  188. height: #{25rpx};
  189. width: #{19rpx};
  190. margin-right: #{5rpx};
  191. }
  192. }
  193. }
  194. .arrow-image {
  195. margin-left: #{36rpx};
  196. width: #{12rpx};
  197. height: #{24rpx};
  198. flex-shrink: 0;
  199. }
  200. }
  201. .empty-box {
  202. width: 100%;
  203. height: 60vh;
  204. display: flex;
  205. justify-content: center;
  206. align-items: center;
  207. flex-direction: column;
  208. image {
  209. width: 280#{rpx};
  210. height: 280#{rpx};
  211. }
  212. span {
  213. margin-top: 15#{rpx};
  214. color: #999;
  215. font-size: 28#{rpx};
  216. }
  217. }
  218. </style>