contract.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="container">
  3. <scroll-view scroll-y class="page" >
  4. <view class="cu-list menu-avatar">
  5. <view class="cu-item" :class="modalName=='move-box-'+ item.id?'move-cur':''" v-for="item in datas" :key="item.id"
  6. @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + item.id">
  7. <view class="cu-avatar radius">
  8. <text class="cuIcon-home"></text>
  9. </view>
  10. <view class="content" style="background-color: #FFFFFF;">
  11. <view class="text-grey">{{item.companyName}}</view>
  12. <view class="text-gray text-sm">
  13. <text class="margin-right-xs cuIcon-calendar"></text> {{item.identificationNo}}
  14. </view>
  15. <view class="text-gray text-sm">
  16. <text class="margin-right-xs cuIcon-phone"></text> {{item.companyPhone}}
  17. </view>
  18. </view>
  19. <view class="move">
  20. <view class='bg-grey' @click='editCompany(item)'>编辑</view>
  21. <view class='bg-red' @click='delCompany(item)'>删除</view>
  22. </view>
  23. </view>
  24. </view>
  25. </scroll-view>
  26. <drag-button
  27. :isDock="true"
  28. :existTabBar="true"
  29. :isIcon="true"
  30. text="新增"
  31. location="20"
  32. @btnClick="Company"
  33. />
  34. </view>
  35. </template>
  36. <script>
  37. import {
  38. mapState
  39. } from 'vuex';
  40. export default {
  41. data() {
  42. return {
  43. datas:[],
  44. listTouchStart: 0,
  45. listTouchDirection: null,
  46. modalName: null,
  47. }
  48. },
  49. computed: {
  50. },
  51. onShow() {
  52. var that=this
  53. this.$api.request('company', 'getCompany', failres => {
  54. that.$api.msg(failres.errmsg)
  55. uni.hideLoading()
  56. }).then(res => {
  57. if(res.data.code=='SUCCESS'){
  58. that.datas=res.data.data
  59. uni.hideLoading()
  60. }else{
  61. that.$api.msg(res.data.code)
  62. uni.hideLoading()
  63. }
  64. })
  65. },
  66. onLoad() {
  67. },
  68. onReady(){
  69. },
  70. methods: {
  71. // ListTouch触摸开始
  72. ListTouchStart(e) {
  73. this.listTouchStart = e.touches[0].pageX
  74. },
  75. // ListTouch计算方向
  76. ListTouchMove(e) {
  77. this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
  78. },
  79. // ListTouch计算滚动
  80. ListTouchEnd(e) {
  81. if (this.listTouchDirection == 'left') {
  82. this.modalName = e.currentTarget.dataset.target
  83. } else {
  84. this.modalName = null
  85. }
  86. this.listTouchDirection = null
  87. },
  88. Company(){
  89. uni.navigateTo({
  90. url: '/pageA/pages/newcompany'
  91. })
  92. },
  93. editCompany(item){
  94. console.log(item.companyName+1)
  95. uni.navigateTo({
  96. url: `/pageA/pages/newcompany?accountNo=${item.accountNo}&companyBank=${item.companyBank}&companyName=${item.companyName}&personNo=${item.personNo}&personName=${item.personName}&personNoImg=${item.personNoImg}&personNoImg1=${item.personNoImg1}&bankImg=${item.bankImg}&bankImg1=${item.bankImg1}&companyPhone=${item.companyPhone}&companyPlace=${item.companyPlace}&identificationNo=${item.identificationNo}&id=${item.id}`
  97. })
  98. },
  99. delCompany(item){
  100. var that =this
  101. var data={}
  102. data.id=item.id
  103. this.$api.request('company', 'deleteCompany', data, failres => {
  104. that.$api.msg(failres.errmsg)
  105. }).then(res => {
  106. if(res.data.code=='SUCCESS'){
  107. that.$api.msg('删除成功')
  108. }else{
  109. that.$api.msg(res.data.code)
  110. }
  111. setTimeout(()=>{uni.navigateBack({
  112. delta: 1
  113. })},1000);
  114. uni.hideLoading()
  115. })
  116. },
  117. },
  118. }
  119. </script>
  120. <style scoped>
  121. .cu-list>.cu-item.move-cur {
  122. -webkit-transform: translateX(-259rpx);
  123. transform: translateX(-259rpx);
  124. }
  125. </style>