西藏巴青项目

index.vue 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <view class="sp-detail-page">
  3. <scroll-view scroll-y class="sp-detail-scroll" enable-back-to-top>
  4. <view v-if="loading" class="sp-empty">
  5. <text class="sp-empty__txt">加载中…</text>
  6. </view>
  7. <template v-else-if="detail">
  8. <view class="sp-block">
  9. <view class="sp-block__head">
  10. <text class="sp-block__title">订单信息</text>
  11. <text class="sp-block__status" :class="statusClass">{{ statusText }}</text>
  12. </view>
  13. <view v-for="field in orderFields" :key="field.label" class="sp-field">
  14. <text class="sp-field__label">{{ field.label }}</text>
  15. <text class="sp-field__value">{{ field.value }}</text>
  16. </view>
  17. </view>
  18. <view class="sp-block">
  19. <text class="sp-block__title sp-block__title--solo">牦牛明细</text>
  20. <view class="sp-line-table">
  21. <view class="sp-line-table__head">
  22. <text class="sp-line-table__th sp-line-table__th--tag">耳标号</text>
  23. <text class="sp-line-table__th">重量(kg)</text>
  24. <text class="sp-line-table__th sp-line-table__th--amt">金额(元)</text>
  25. <text class="sp-line-table__th sp-line-table__th--act">操作</text>
  26. </view>
  27. <view v-if="!lineList.length" class="sp-line-table__empty">
  28. <text class="sp-line-table__empty-txt">暂无明细</text>
  29. </view>
  30. <view v-for="(line, idx) in lineList" :key="line.id || idx" class="sp-line-table__row">
  31. <text class="sp-line-table__td sp-line-table__td--tag">{{ line.earTag || DASH }}</text>
  32. <text class="sp-line-table__td">{{ line.weight != null ? line.weight : DASH }}</text>
  33. <text class="sp-line-table__td sp-line-table__td--amt">{{ formatPrice(line.amount) }}</text>
  34. <text class="sp-line-table__td sp-line-table__td--act sp-line-table__link" @tap.stop="openYak(line)">查看</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="sp-block">
  39. <text class="sp-block__title sp-block__title--solo">支付信息</text>
  40. <view class="sp-field">
  41. <text class="sp-field__label">订单支付时间</text>
  42. <text class="sp-field__value">{{ formatDateTime(detail.finishTime) }}</text>
  43. </view>
  44. <view class="sp-voucher-row">
  45. <text class="sp-field__label">支付凭证</text>
  46. <image
  47. v-if="payVoucherUrl"
  48. class="sp-voucher-img"
  49. :src="payVoucherUrl"
  50. mode="aspectFill"
  51. @tap="previewImage(payVoucherUrl)"
  52. />
  53. <view v-else class="sp-voucher-placeholder">
  54. <text class="sp-voucher-placeholder__txt">暂无</text>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <view v-else class="sp-empty">
  60. <text class="sp-empty__txt">订单不存在或无权查看</text>
  61. </view>
  62. <view class="sp-footer-spacer" />
  63. </scroll-view>
  64. </view>
  65. </template>
  66. <script>
  67. import { getDistributorOrder } from '@/api/distributor/order'
  68. import { resolveResourceUrl } from '@/utils/resourceUrl'
  69. import { DASH, formatDateTime, formatPrice } from '@/utils/format'
  70. export default {
  71. data() {
  72. return {
  73. DASH,
  74. id: '',
  75. loading: false,
  76. detail: null
  77. }
  78. },
  79. computed: {
  80. lineList() {
  81. return (this.detail && this.detail.lineList) || []
  82. },
  83. statusText() {
  84. return (this.detail && this.detail.orderStatusName) || DASH
  85. },
  86. statusClass() {
  87. const text = this.statusText
  88. if (String(text).includes('完成')) return 'sp-block__status--done'
  89. if (String(text).includes('待')) return 'sp-block__status--pending'
  90. return ''
  91. },
  92. orderFields() {
  93. const d = this.detail || {}
  94. return [
  95. { label: '订单编号', value: d.orderNo || DASH },
  96. { label: '订单创建时间', value: formatDateTime(d.createTime) },
  97. { label: '供应商', value: d.supplierName || DASH },
  98. { label: '承销商', value: d.distributorName || DASH },
  99. { label: '交易总头数(头)', value: d.totalHeads != null ? d.totalHeads : DASH },
  100. { label: '交易总金额(元)', value: formatPrice(d.totalAmount) }
  101. ]
  102. },
  103. payVoucherUrl() {
  104. const d = this.detail
  105. return resolveResourceUrl(d && (d.payVoucherUrl || d.payVoucherPath))
  106. }
  107. },
  108. onLoad(query) {
  109. this.id = query.id || ''
  110. this.loadDetail()
  111. },
  112. methods: {
  113. formatDateTime,
  114. formatPrice,
  115. loadDetail() {
  116. if (!this.id) return
  117. this.loading = true
  118. getDistributorOrder(this.id)
  119. .then((res) => {
  120. this.detail = res.data || null
  121. })
  122. .catch(() => {
  123. this.detail = null
  124. })
  125. .finally(() => {
  126. this.loading = false
  127. })
  128. },
  129. previewImage(url) {
  130. if (!url) return
  131. uni.previewImage({ urls: [url], current: url })
  132. },
  133. openYak(line) {
  134. const supplierId = line.supplierId || this.detail.supplierId
  135. const earTag = line.earTag
  136. if (!supplierId || !earTag) {
  137. uni.showToast({ title: '缺少牦牛信息', icon: 'none' })
  138. return
  139. }
  140. uni.navigateTo({
  141. url: `/pages/distributor/yak-detail/index?supplierId=${supplierId}&earTag=${encodeURIComponent(earTag)}`
  142. })
  143. }
  144. }
  145. }
  146. </script>
  147. <style lang="scss" scoped>
  148. @import '@/styles/morandi.scss';
  149. @import '@/styles/detail-page.scss';
  150. .sp-detail-page {
  151. @include detail-page-root;
  152. }
  153. .sp-detail-scroll {
  154. @include detail-page-scroll;
  155. }
  156. .sp-block {
  157. margin: 24rpx 24rpx 0;
  158. padding: 24rpx;
  159. border-radius: 16rpx;
  160. background: $morandi-bg-card;
  161. border: 1rpx solid $morandi-border-soft;
  162. }
  163. .sp-block__head {
  164. display: flex;
  165. flex-direction: row;
  166. align-items: center;
  167. justify-content: space-between;
  168. margin-bottom: 20rpx;
  169. }
  170. .sp-block__title {
  171. font-size: 30rpx;
  172. font-weight: 600;
  173. color: $morandi-text;
  174. }
  175. .sp-block__title--solo {
  176. display: block;
  177. margin-bottom: 20rpx;
  178. }
  179. .sp-block__status {
  180. font-size: 26rpx;
  181. color: $morandi-text-secondary;
  182. }
  183. .sp-block__status--pending {
  184. color: #ea580c;
  185. }
  186. .sp-block__status--done {
  187. color: #16a34a;
  188. }
  189. .sp-field {
  190. display: flex;
  191. flex-direction: row;
  192. align-items: flex-start;
  193. justify-content: space-between;
  194. gap: 24rpx;
  195. padding: 14rpx 0;
  196. border-bottom: 1rpx solid $morandi-border-soft;
  197. }
  198. .sp-field:last-child {
  199. border-bottom-width: 0;
  200. }
  201. .sp-field__label {
  202. flex-shrink: 0;
  203. font-size: 26rpx;
  204. color: $morandi-text-muted;
  205. }
  206. .sp-field__value {
  207. flex: 1;
  208. min-width: 0;
  209. font-size: 26rpx;
  210. color: $morandi-text;
  211. text-align: right;
  212. word-break: break-all;
  213. }
  214. .sp-line-table__head,
  215. .sp-line-table__row {
  216. display: flex;
  217. flex-direction: row;
  218. align-items: center;
  219. padding: 12rpx 0;
  220. }
  221. .sp-line-table__head {
  222. border-bottom: 1rpx solid $morandi-border-soft;
  223. }
  224. .sp-line-table__row {
  225. border-bottom: 1rpx solid $morandi-border-soft;
  226. }
  227. .sp-line-table__row:last-child {
  228. border-bottom-width: 0;
  229. }
  230. .sp-line-table__th,
  231. .sp-line-table__td {
  232. flex: 1;
  233. font-size: 24rpx;
  234. color: $morandi-text-secondary;
  235. text-align: center;
  236. }
  237. .sp-line-table__th {
  238. font-weight: 600;
  239. color: $morandi-text-muted;
  240. }
  241. .sp-line-table__th--tag,
  242. .sp-line-table__td--tag {
  243. flex: 1.1;
  244. text-align: left;
  245. }
  246. .sp-line-table__th--amt,
  247. .sp-line-table__td--amt {
  248. flex: 1;
  249. text-align: right;
  250. }
  251. .sp-line-table__th--act,
  252. .sp-line-table__td--act {
  253. flex: 0.8;
  254. text-align: right;
  255. }
  256. .sp-line-table__link {
  257. color: #2563eb;
  258. }
  259. .sp-line-table__empty {
  260. padding: 24rpx 0;
  261. text-align: center;
  262. }
  263. .sp-line-table__empty-txt {
  264. font-size: 24rpx;
  265. color: $morandi-text-muted;
  266. }
  267. .sp-voucher-row {
  268. display: flex;
  269. flex-direction: row;
  270. align-items: center;
  271. justify-content: space-between;
  272. padding-top: 16rpx;
  273. }
  274. .sp-voucher-img {
  275. width: 120rpx;
  276. height: 120rpx;
  277. border-radius: 8rpx;
  278. background: #e5e7eb;
  279. }
  280. .sp-voucher-placeholder {
  281. width: 120rpx;
  282. height: 120rpx;
  283. border-radius: 8rpx;
  284. background: #f3f4f6;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. }
  289. .sp-voucher-placeholder__txt {
  290. font-size: 22rpx;
  291. color: $morandi-text-muted;
  292. }
  293. .sp-empty {
  294. padding: 80rpx 24rpx;
  295. text-align: center;
  296. }
  297. .sp-empty__txt {
  298. font-size: 28rpx;
  299. color: $morandi-text-muted;
  300. }
  301. .sp-footer-spacer {
  302. height: 40rpx;
  303. }
  304. </style>