diningList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view>
  3. <view class="btnS">
  4. <view style="width: 90%;">
  5. <u-search :clearabled="true" shape="round" :showAction="false" v-model="seaName"
  6. @search="searchClick"></u-search>
  7. </view>
  8. </view>
  9. <view class="contain" style="margin: 10px 0;" v-for="(item, index) in tableData" :key="index" @click.self="carList(item)">
  10. <view class="box" :class="{ 'boxed-border': currentData.id == item.id }">
  11. <view class="container">
  12. <view class="text-container">
  13. <view class="flex-item">{{item.name ? item.name : '无' }}</view>
  14. <u-tag plain :text="item.openState ? '营业中' : '离线'" :type="item.openState ? 'success' : 'error'"
  15. size="mini"></u-tag>
  16. </view>
  17. </view>
  18. <view class="icon-container">
  19. <u-icon name="phone" size="28" @click.prevent="call(item)" aa='1'></u-icon>
  20. <u-icon style="margin-left: 10px;" name="info-circle" size="28" @click.stop="btnIC(item)"></u-icon>
  21. </view>
  22. <view :class="{ 'btnbor': currentData.id== item.id }" v-if="currentData.id == item.id">
  23. <!-- <u-tag text="当前" bgColor='#FF6D20' borderColor='#FF6D20' icon="checkmark-circle"></u-tag> -->
  24. <image src="../../static/danqian.png" class="img-ding"></image>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. seaName: '',
  35. orderinfo: {},
  36. tableData: [
  37. {
  38. name: '23333',
  39. tags: 1,
  40. showBorder: true,
  41. },
  42. {
  43. name: '门店',
  44. tags: 1,
  45. showBorder: false,
  46. },
  47. {
  48. name: '店家',
  49. tags: 1,
  50. showBorder: false,
  51. }
  52. ],
  53. page: {
  54. pageNum: 1,
  55. pageSize: 20,
  56. total: 0,
  57. totalPage: 0
  58. },
  59. currentData:null,
  60. status: 'loading'
  61. }
  62. },
  63. created() {
  64. this.fatchDate()
  65. },
  66. onLoad() {
  67. this.currentData = uni.getStorageSync("carl");
  68. },
  69. methods: {
  70. searchClick(e) {
  71. this.seaName = e
  72. this.fatchDate()
  73. console.log('==============================', e)
  74. },
  75. call(item) {
  76. if (item.customerPhone) {
  77. uni.makePhoneCall({
  78. phoneNumber: item.customerPhone
  79. });
  80. } else {
  81. uni.showToast({
  82. icon: 'none',
  83. title: '暂无商家电话'
  84. })
  85. }
  86. },
  87. btnIC(e) {
  88. console.log('e=================', e)
  89. uni.navigateTo({
  90. url: `/pages/diningCar/diningCar?id=${e.id}`
  91. })
  92. },
  93. carList(e) {
  94. const carl = {
  95. id: e.id,
  96. customerPhone: e.customerPhone,
  97. name: e.name,
  98. openState: e.openState
  99. }
  100. uni.setStorageSync("carl", carl)
  101. console.log('---------------------', carl)
  102. uni.switchTab({
  103. url: `/pages/home/home`
  104. })
  105. },
  106. async fatchDate() {
  107. var queryParams = {
  108. "pageSize": this.page.pageSize,
  109. "pageNum": this.page.pageNum,
  110. "name": this.seaName,
  111. "isAsc": "desc",
  112. "orderByColumn": "createTime"
  113. }
  114. try {
  115. const response = await this.$request('post', '/sale/diningCar/queryDiningCar', queryParams);
  116. console.log('response', response)
  117. const data = response.rows; // 假设 res.rows 是一个数组
  118. console.log('response.rows', response.rows);
  119. if (response.code === 200) {
  120. const li = data;
  121. if (this.page.pageNum === 1) {
  122. this.tableData = li;
  123. } else {
  124. this.tableData = this.tableData.concat(li);
  125. }
  126. this.page.total = data.count;
  127. this.page.totalPage = Math.ceil(data.count / this.page.pageSize);
  128. this.status = this.page.totalPage === 0 || this.page.totalPage === this.page.pageNum ?
  129. 'noMore' : 'more';
  130. } else {
  131. //this.$toast(data.msg);
  132. }
  133. } catch (err) {
  134. console.error('请求异常', err);
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. .box {
  142. padding: 20rpx 20rpx 0;
  143. height: 80px;
  144. border-bottom-left-radius: 30rpx;
  145. border-bottom-right-radius: 30rpx;
  146. background-position: top;
  147. box-shadow: 0 0 5px 2px #ebebeb;
  148. background-repeat: no-repeat;
  149. border-radius: 20rpx;
  150. background-color: #fff;
  151. .btnbor {
  152. position: absolute;
  153. /* 设置为绝对定位 */
  154. right: 16px;
  155. /* 相对于父元素的右边缘 */
  156. bottom: 30px;
  157. /* 相对于父元素的下边缘 */
  158. margin: 0;
  159. /* 清除 margin 属性 */
  160. padding: 0;
  161. /* 清除 padding 属性 */
  162. &::after {
  163. content: '';
  164. display: block;
  165. width: 100%;
  166. height: 100%;
  167. border: 1px solid #FF6D20;
  168. border-radius: 20rpx;
  169. position: absolute;
  170. top: 0;
  171. right: 0;
  172. background-color: #fff;
  173. z-index: -1;
  174. /* 使边框在图片下面 */
  175. }
  176. }
  177. }
  178. .boxed-border {
  179. border: 1px solid #FF6D20;
  180. /* 边框样式 */
  181. padding: 20rpx 20rpx 0;
  182. border-radius: 20rpx;
  183. /* 添加圆角 */
  184. // .btnbor {
  185. // margin-right: -11px;
  186. // margin-top: -15px;
  187. // float: right;
  188. // }
  189. }
  190. .box:hover {
  191. border: 1px solid #FF6D20;
  192. /* 鼠标悬停时显示边框 */
  193. }
  194. .box:active {
  195. border: 1px solid #F54319;
  196. /* 鼠标按下时显示另一种边框颜色 */
  197. }
  198. .container {
  199. display: flex;
  200. /* 使用 Flexbox 布局 */
  201. justify-content: space-between;
  202. /* 子元素之间留有空白 */
  203. }
  204. .text-container {
  205. display: flex;
  206. flex-direction: column;
  207. align-items: flex-start;
  208. /* 左对齐 */
  209. }
  210. .flex-item {
  211. margin-bottom: 10px;
  212. }
  213. .tag-item {
  214. margin-left: auto;
  215. /* 将标签推到右边 */
  216. }
  217. .icon-container {
  218. display: flex;
  219. /* 使用 Flexbox 布局 */
  220. flex-direction: row;
  221. /* 水平排列子元素 */
  222. justify-content: flex-end;
  223. /* 子元素右对齐 */
  224. margin-top: -55px;
  225. right: 0;
  226. bottom: 0;
  227. gap: 10px;
  228. /* 设置图标之间的距离 */
  229. }
  230. .img-ding {
  231. width: 83px;
  232. height: 30px;
  233. position: absolute;
  234. right: 0;
  235. top: 0;
  236. margin: 0; // 清除 margin 属性,以避免与边框重叠
  237. }
  238. .btnS {
  239. display: flex;
  240. justify-content: center;
  241. align-items: center;
  242. margin-top: 5px;
  243. }
  244. </style>