waitOrderDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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.toFixed(2)
  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.toFixed(2)
  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. typeName: k.dispName,
  191. typeList: []
  192. }
  193. console.log(p,'pppppp')
  194. this.list.push(p)
  195. })
  196. // console.log(this.list,'this.list----------')
  197. this.curType = this.typeData.length ? this.typeData[0].code : ''
  198. this.curIndex = 0
  199. this.getRow()
  200. } else {
  201. this.typeData = []
  202. }
  203. })
  204. },
  205. // 查询列表
  206. getRow(code,num) {
  207. this.curType = code || this.curType
  208. this.curIndex = num || 0
  209. if(this.list[this.curIndex].typeList.length) return
  210. reservePriceFind({code:this.curType}).then(res => {
  211. if (res.status == 200) {
  212. let data = res.data
  213. data.forEach(item =>{
  214. item.rubbishWeight = ''
  215. item.totalAmount = ''
  216. })
  217. this.list[this.curIndex].typeList = data
  218. // console.log(this.list,'----this.list')
  219. } else {
  220. this.list[this.curIndex].typeList = []
  221. this.total = 0
  222. this.noDataText = res.message
  223. }
  224. })
  225. },
  226. // 选择支付方式
  227. chooseType(code) {
  228. this.payType = code
  229. console.log(this.payType,'this.payType')
  230. },
  231. // 提交
  232. submit() {
  233. let arr = [] // 有重量也有价格
  234. let arrP = [] // 有重量没有价格
  235. this.list.map(item =>{
  236. item.typeList.map(k =>{
  237. if(k.rubbishWeight && k.customerPrice) {
  238. let p = {
  239. rubbishType: item.typeCode, //垃圾大类型
  240. rubbishTypeItem: k.code, // 垃圾细分类型
  241. rubbishWeight: k.rubbishWeight*1000, // 垃圾重量(克)
  242. rubbishPrice: k.customerPrice, // 单价
  243. totalAmount: k.rubbishWeight* k.customerPrice // 总价金额
  244. }
  245. arr.push(p)
  246. }
  247. if(k.rubbishWeight && !k.customerPrice) {
  248. let p = {
  249. name: item.typeName,
  250. itemName: k.name
  251. }
  252. arrP.push(p)
  253. }
  254. })
  255. })
  256. if(arrP.length) {
  257. uni.showToast({
  258. title: `请输入【 ${arrP[0].name} 】中 【${arrP[0].itemName}】的价格!`,
  259. icon: 'none',
  260. duration: 3000
  261. })
  262. return
  263. }
  264. if(arr.length==0) {
  265. uni.showToast({
  266. title: '请先输入重量且合计金额必须大于0!',
  267. icon: 'none'
  268. })
  269. return
  270. }
  271. let item = arr.find(item=>!item.rubbishPrice)
  272. if(item) {
  273. uni.showToast({
  274. title: '请先输入重量且合计金额必须大于0!',
  275. icon: 'none'
  276. })
  277. return
  278. }
  279. if (!this.payType) {
  280. uni.showToast({
  281. title: '请选择支付方式!',
  282. icon: 'none'
  283. })
  284. return
  285. }
  286. let params = {
  287. "payType": this.payType, //支付方式
  288. originalAmount: this.originalAmount, // 支付总金额
  289. totalWeight: this.totalWeight*1000, // 总重量(g)
  290. contactName: this.orderInfo.contactName, //联系人姓名
  291. contactMobile: this.orderInfo.contactMobile, //联系人手机号
  292. contactAddress: this.orderInfo.contactAddress,//联系人地址
  293. orderReserveNo: this.orderReserveNo,
  294. orderReserveItemEntityList: arr
  295. }
  296. this.loading = true
  297. orderSubmit(params).then(res=>{
  298. if(res.status == 200) {
  299. uni.showToast({
  300. title: res.message,
  301. icon: 'none'
  302. })
  303. console.log('=============跳转')
  304. uni.redirectTo({
  305. url: '/pages/order/finish?money=' + res.data
  306. })
  307. }
  308. this.loading = false
  309. })
  310. }
  311. },
  312. }
  313. </script>
  314. <style lang="scss">
  315. .order-pages {
  316. width: 100%;
  317. height: 100vh;
  318. display: flex;
  319. flex-direction: column;
  320. background-color: #F5F5F5;
  321. .order-info {
  322. width: 100%;
  323. flex: 1;
  324. overflow-y: scroll;
  325. // 订单内容
  326. .info-main{
  327. background: #ffffff;
  328. padding: 10upx 32upx;
  329. margin: 20upx 32upx;
  330. border-radius: 24upx;
  331. box-shadow: 1px 1px 3px #EEEEEE;
  332. font-size: 28upx;
  333. background-image: url(../../static/order_bg_stor.png);
  334. background-repeat: no-repeat;
  335. background-size: contain;
  336. .new-left{
  337. width: 360rpx;
  338. font-size: 36rpx;
  339. color: #191919;
  340. font-weight: 600;
  341. line-height: 44rpx;
  342. margin-top: 30rpx;
  343. min-height: 80rpx;
  344. }
  345. .time{
  346. padding: 20rpx 0;
  347. font-size: 32rpx;
  348. color: #7C7D7E;
  349. margin-top: 20rpx;
  350. view:last-child{
  351. font-size: 28rpx;
  352. color: #4C4C4C;
  353. margin-left: 6rpx;
  354. }
  355. }
  356. }
  357. // 状态
  358. .order-status {
  359. padding: 30upx 0;
  360. text-align: center;
  361. .status-title {
  362. font-size: 42upx;
  363. color: #191919;
  364. .icon{
  365. width: 48rpx;
  366. height: 48rpx;
  367. margin-right: 10rpx;
  368. }
  369. }
  370. .status-care {
  371. font-size: 28upx;
  372. margin-top: 10upx;
  373. color: #191919;
  374. >text {
  375. color: red;
  376. }
  377. }
  378. }
  379. // 订单信息列
  380. .item-info{
  381. border-radius: 24rpx;
  382. margin: 0rpx 32rpx 20rpx;
  383. padding: 0rpx 32rpx;
  384. background-color: #fff;
  385. .item-title{
  386. font-size: 32rpx;
  387. color: #181818;
  388. padding-top: 28rpx;
  389. .care{
  390. font-size: 24rpx;
  391. color: #FF2C5C;
  392. margin-top: 10rpx;
  393. }
  394. }
  395. .table{
  396. padding: 20rpx 0;
  397. display: flex;
  398. font-size: 28rpx;
  399. view{
  400. width: 33%;
  401. text-align: center;
  402. }
  403. }
  404. .item{
  405. padding: 28rpx 0;
  406. font-size: 32rpx;
  407. border-bottom: 1px solid #EBEBEB;
  408. .item-name{
  409. max-width: 100rpx;
  410. font-size: 30rpx;
  411. }
  412. :first-child{
  413. color: #7C7D7E;
  414. }
  415. :last-child-child{
  416. color: #222222;
  417. }
  418. &:last-child{
  419. border-bottom: none;
  420. }
  421. .input-left{
  422. padding: 6rpx;
  423. border-bottom: 1px solid #707070;
  424. }
  425. .item-type{
  426. padding: 10rpx 14rpx;
  427. border: 1px solid #979797;
  428. opacity: 1;
  429. border-radius: 30rpx;
  430. font-size: 30rpx;
  431. color: #999999;
  432. text-align: center;
  433. }
  434. .item-type.active{
  435. background-color: #4F88F7;
  436. border: none;
  437. color: #fff;
  438. }
  439. }
  440. }
  441. .price-text {
  442. font-size: 20upx;
  443. margin-left: 10upx;
  444. }
  445. .price-num {
  446. font-size: 32upx;
  447. color: red;
  448. font-weight: 600;
  449. margin-right: 6rpx;
  450. }
  451. .u-cell {
  452. padding: 10rpx 32rpx;
  453. }
  454. }
  455. .footer {
  456. padding: 20rpx 32rpx;
  457. display: flex;
  458. background-color: #fff;
  459. }
  460. }
  461. </style>