waitOrderDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="order-pages">
  3. <view class="order-info">
  4. <!-- 订单状态 -->
  5. <view class="order-status">
  6. <view class="status-title flex align_center justify_center">
  7. <u-icon class="icon" name="icon_service"
  8. custom-prefix="custom-icon" size="48" color="#333333"></u-icon>
  9. {{orderInfo.orderStatusDictValue || '--'}}
  10. </view>
  11. <view class="status-care">
  12. 预约时间:{{orderInfo.reserveTime || '--'}}
  13. </view>
  14. </view>
  15. <!-- 回收品类明细 -->
  16. <view class="item-info">
  17. <view class="item-title">
  18. <view>回收品类明细</view>
  19. <view class="care">(切换分类可输入不同回收物的价格和重量)</view>
  20. </view>
  21. <view class="item flex justify_between">
  22. <view :class="['item-type', curType == item.code ? 'active' : '']" v-for="(item,index) in typeData" :key="item.id" @click="getRow(item.code,index)">
  23. {{item.dispName}}
  24. </view>
  25. </view>
  26. <view class="table">
  27. <view>单价(元/kg)</view>
  28. <view>重量(kg)</view>
  29. <view>合计金额(元)</view>
  30. </view>
  31. <view v-if="list.length && list[curIndex].typeList.length" v-for="(item,index) in list[curIndex].typeList" :key="item.id" class="item flex justify_between align_center">
  32. <view class="flex align_center">
  33. <text class="item-name">{{item.name}}</text>
  34. <u-input type="digit" @input="numberToFixed(item,'customerPrice',index)" :custom-style="inputLeftStyle" input-align="center" :clearable="false" v-model="item.customerPrice" placeholder="输入单价" />
  35. </view>
  36. <view class="flex flex_1 align_center">
  37. <u-input type="digit" @input="numberToFixed(item,'rubbishWeight',index)" :custom-style="inputRightStyle" input-align="center" :clearable="false" v-model="item.rubbishWeight" placeholder="请输入重量" />
  38. </view>
  39. <view class="flex_1 flex align_center justify_center">{{item.totalAmount}}</view>
  40. </view>
  41. </view>
  42. <!-- 金额 -->
  43. <view class="item-info">
  44. <view class="item flex justify_between">
  45. <text>应付金额</text>
  46. <text>{{originalAmount}} 元</text>
  47. </view>
  48. <view class="item flex justify_between">
  49. <text>支付方式</text>
  50. <v-select class="flex_1" ref="payType" :disabled="true" placeholder="请选择支付方式" @itemChange="chooseType" code="ORDER_RESERVE_PAY_TYPE" style="width: 100%"></v-select>
  51. </view>
  52. </view>
  53. <!-- 服务信息 -->
  54. <view class="info-main flex flex_column">
  55. <view class="flex flex_1 align_center">
  56. <view class="new-left">
  57. {{orderInfo.contactAddress + (orderInfo.houseAddress||'')}}
  58. </view>
  59. </view>
  60. <view class="time flex align_center justify_between">
  61. <text>{{orderInfo.contactName}}</text>
  62. <view @click="callPhone(orderInfo.contactMobile)" class="flex align_center">
  63. <u-icon class="phone" name="icon_phone" custom-prefix="custom-icon" size="28" color="#999999"></u-icon>
  64. <text>{{orderInfo.contactMobile}}</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="footer">
  70. <u-button @click="submit" :loading="loading" class="flex_1" type="primary">提交</u-button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import moment from 'moment'
  76. import { orderDetailFind, orderSubmit } from '@/api/order.js'
  77. import { getLookUpDatas } from '@/api/data.js'
  78. import { reservePriceFind } from '@/api/index.js'
  79. import vSelect from '@/components/select/v-select.vue'
  80. import {numberToFixed} from '@/libs/tools.js'
  81. export default {
  82. components: {
  83. vSelect
  84. },
  85. data() {
  86. return {
  87. orderInfo: {},
  88. totalPrice: 0, // 支付合计
  89. orderReserveNo: '', // 订单号
  90. inputLeftStyle: {
  91. Width: '110rpx',
  92. borderBottom: '1px solid #707070',
  93. padding: '0rpx 10rpx',
  94. color: '#191919'
  95. },
  96. inputRightStyle:{
  97. padding: '0rpx 10rpx',
  98. color: '#191919'
  99. },
  100. curType: '', // 当前类型
  101. curIndex: 0, // 当前类型index
  102. typeData: [], // 垃圾类型数据
  103. list: [],
  104. payType: '', // 支付方式
  105. loading: false
  106. }
  107. },
  108. onLoad(options) {
  109. if (options.orderNo) {
  110. console.log(options.orderNo)
  111. this.orderReserveNo = options.orderNo
  112. this.getOrderDetail()
  113. this.getRubbishType()
  114. }
  115. // 开启分享
  116. uni.showShareMenu({
  117. withShareTicket: true,
  118. menus: ['shareAppMessage', 'shareTimeline']
  119. })
  120. },
  121. computed: {
  122. // 支付总金额
  123. originalAmount() {
  124. let total = 0
  125. if(this.list.length){
  126. this.list.map(item =>{
  127. item.typeList.map(k =>{
  128. if(k.totalAmount){
  129. total = total + Number(k.totalAmount)
  130. }
  131. })
  132. })
  133. }
  134. return total
  135. },
  136. // 总重量
  137. totalWeight() {
  138. let total = 0
  139. if(this.list.length){
  140. this.list.map(item =>{
  141. item.typeList.map(k =>{
  142. total = total + Number(k.rubbishWeight)
  143. })
  144. })
  145. }
  146. return total
  147. }
  148. },
  149. methods: {
  150. // 小数点后两位
  151. numberToFixed: function (item,key, index) {
  152. let val = item[key]
  153. let ret = numberToFixed(val, 2, 999999)
  154. this.$nextTick(() => {
  155. item[key] = Number(ret)
  156. item.totalAmount = item.customerPrice ?(item.customerPrice * item.rubbishWeight).toFixed(2) : 0
  157. })
  158. },
  159. // 打电话
  160. callPhone(phone) {
  161. uni.makePhoneCall({
  162. phoneNumber: phone
  163. });
  164. },
  165. // 获取订单详情
  166. getOrderDetail() {
  167. uni.showLoading({
  168. title: '加载中...'
  169. })
  170. orderDetailFind({
  171. orderReserveNo: this.orderReserveNo
  172. }).then(res => {
  173. console.log(res,'rrrrrrrr')
  174. if (res.status == 200 && res.data) {
  175. this.orderInfo = res.data
  176. this.orderInfo.reserveTime = moment(this.orderInfo.reserveDateBegin).format('YYYY-MM-DD') + this.orderInfo.reserveTimeTypeDictValue
  177. }
  178. uni.hideLoading()
  179. })
  180. },
  181. // 获取垃圾类型数据
  182. getRubbishType() {
  183. this.list = []
  184. getLookUpDatas({type:'RESERVE_RUBBISH_TYPE'}).then(res=>{
  185. if(res.status == 200) {
  186. this.typeData = res.data || []
  187. this.typeData.map(k =>{
  188. let p = {
  189. typeCode: k.code,
  190. typeList: []
  191. }
  192. console.log(p,'pppppp')
  193. this.list.push(p)
  194. })
  195. // console.log(this.list,'this.list----------')
  196. this.curType = this.typeData.length ? this.typeData[0].code : ''
  197. this.curIndex = 0
  198. this.getRow()
  199. } else {
  200. this.typeData = []
  201. }
  202. })
  203. },
  204. // 查询列表
  205. getRow(code,num) {
  206. this.curType = code || this.curType
  207. this.curIndex = num || 0
  208. if(this.list[this.curIndex].typeList.length) return
  209. reservePriceFind({code:this.curType}).then(res => {
  210. if (res.status == 200) {
  211. let data = res.data
  212. data.forEach(item =>{
  213. item.rubbishWeight = ''
  214. item.totalAmount = ''
  215. })
  216. this.list[this.curIndex].typeList = data
  217. // console.log(this.list,'----this.list')
  218. } else {
  219. this.list[this.curIndex].typeList = []
  220. this.total = 0
  221. this.noDataText = res.message
  222. }
  223. })
  224. },
  225. // 选择支付方式
  226. chooseType(code) {
  227. this.payType = code
  228. console.log(this.payType,'this.payType')
  229. },
  230. // 提交
  231. submit() {
  232. let arr = []
  233. this.list.map(item =>{
  234. item.typeList.map(k =>{
  235. if(k.rubbishWeight && k.customerPrice) {
  236. let p = {
  237. rubbishType: item.typeCode, //垃圾大类型
  238. rubbishTypeItem: k.code, // 垃圾细分类型
  239. rubbishWeight: k.rubbishWeight*1000, // 垃圾重量(克)
  240. rubbishPrice: k.customerPrice, // 单价
  241. totalAmount: k.rubbishWeight* k.customerPrice // 总价金额
  242. }
  243. arr.push(p)
  244. }
  245. })
  246. })
  247. if(arr.length==0) {
  248. uni.showToast({
  249. title: '请先输入重量且合计金额必须大于0!',
  250. icon: 'none'
  251. })
  252. return
  253. }
  254. if (!this.payType) {
  255. uni.showToast({
  256. title: '请选择支付方式!',
  257. icon: 'none'
  258. })
  259. return
  260. }
  261. let params = {
  262. "payType": this.payType, //支付方式
  263. originalAmount: this.originalAmount, // 支付总金额
  264. totalWeight: this.totalWeight*1000, // 总重量(g)
  265. contactName: this.orderInfo.contactName, //联系人姓名
  266. contactMobile: this.orderInfo.contactMobile, //联系人手机号
  267. contactAddress: this.orderInfo.contactAddress,//联系人地址
  268. orderReserveNo: this.orderReserveNo,
  269. orderReserveItemEntityList: arr
  270. }
  271. this.loading = true
  272. orderSubmit(params).then(res=>{
  273. if(res.status == 200) {
  274. uni.showToast({
  275. title: res.message,
  276. icon: 'none'
  277. })
  278. uni.redirectTo({
  279. url: '/pages/order/finish?money=' + res.data
  280. })
  281. }
  282. this.loading = false
  283. })
  284. }
  285. },
  286. }
  287. </script>
  288. <style lang="scss">
  289. .order-pages {
  290. width: 100%;
  291. height: 100vh;
  292. display: flex;
  293. flex-direction: column;
  294. background-color: #F5F5F5;
  295. .order-info {
  296. width: 100%;
  297. flex: 1;
  298. overflow-y: scroll;
  299. // 订单内容
  300. .info-main{
  301. background: #ffffff;
  302. padding: 10upx 32upx;
  303. margin: 20upx 32upx;
  304. border-radius: 24upx;
  305. box-shadow: 1px 1px 3px #EEEEEE;
  306. font-size: 28upx;
  307. background-image: url(../../static/order_bg_stor.png);
  308. background-repeat: no-repeat;
  309. background-size: contain;
  310. .new-left{
  311. width: 360rpx;
  312. font-size: 36rpx;
  313. color: #191919;
  314. font-weight: 600;
  315. line-height: 44rpx;
  316. margin-top: 30rpx;
  317. min-height: 80rpx;
  318. }
  319. .time{
  320. padding: 20rpx 0;
  321. font-size: 32rpx;
  322. color: #7C7D7E;
  323. margin-top: 20rpx;
  324. view:last-child{
  325. font-size: 28rpx;
  326. color: #4C4C4C;
  327. margin-left: 6rpx;
  328. }
  329. }
  330. }
  331. // 状态
  332. .order-status {
  333. padding: 30upx 0;
  334. text-align: center;
  335. .status-title {
  336. font-size: 42upx;
  337. color: #191919;
  338. .icon{
  339. width: 48rpx;
  340. height: 48rpx;
  341. margin-right: 10rpx;
  342. }
  343. }
  344. .status-care {
  345. font-size: 28upx;
  346. margin-top: 10upx;
  347. color: #191919;
  348. >text {
  349. color: red;
  350. }
  351. }
  352. }
  353. // 订单信息列
  354. .item-info{
  355. border-radius: 24rpx;
  356. margin: 0rpx 32rpx 20rpx;
  357. padding: 0rpx 32rpx;
  358. background-color: #fff;
  359. .item-title{
  360. font-size: 32rpx;
  361. color: #181818;
  362. padding-top: 28rpx;
  363. .care{
  364. font-size: 24rpx;
  365. color: #FF2C5C;
  366. margin-top: 10rpx;
  367. }
  368. }
  369. .table{
  370. padding: 20rpx 0;
  371. display: flex;
  372. font-size: 28rpx;
  373. view{
  374. width: 33%;
  375. text-align: center;
  376. }
  377. }
  378. .item{
  379. padding: 28rpx 0;
  380. font-size: 32rpx;
  381. border-bottom: 1px solid #EBEBEB;
  382. .item-name{
  383. max-width: 100rpx;
  384. font-size: 30rpx;
  385. }
  386. :first-child{
  387. color: #7C7D7E;
  388. }
  389. :last-child-child{
  390. color: #222222;
  391. }
  392. &:last-child{
  393. border-bottom: none;
  394. }
  395. .input-left{
  396. padding: 6rpx;
  397. border-bottom: 1px solid #707070;
  398. }
  399. .item-type{
  400. padding: 10rpx 14rpx;
  401. border: 1px solid #979797;
  402. opacity: 1;
  403. border-radius: 30rpx;
  404. font-size: 30rpx;
  405. color: #999999;
  406. text-align: center;
  407. }
  408. .item-type.active{
  409. background-color: #4F88F7;
  410. border: none;
  411. color: #fff;
  412. }
  413. }
  414. }
  415. .price-text {
  416. font-size: 20upx;
  417. margin-left: 10upx;
  418. }
  419. .price-num {
  420. font-size: 32upx;
  421. color: red;
  422. font-weight: 600;
  423. margin-right: 6rpx;
  424. }
  425. .u-cell {
  426. padding: 10rpx 32rpx;
  427. }
  428. }
  429. .footer {
  430. padding: 20rpx 32rpx;
  431. display: flex;
  432. background-color: #fff;
  433. }
  434. }
  435. </style>