OrderSend.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div seller-order-send">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="订单发货" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <!-- header -->
  14. <view class="div main-content">
  15. <view class="div daddress_info" @click="goAddress">
  16. <view class="div top-wrapper">
  17. <flex-line class="selected-wrapper" v-if="daddress_info" :show-border="true">
  18. <view class="div line">
  19. <text class="i icon iconfont">&#xe6d3;</text>
  20. <view class="div line-content">
  21. <view class="div title-wrapper">
  22. <label class="title">{{daddress_info.seller_name}}</label>
  23. <label class="title" style="margin-left:1rem;">{{daddress_info.daddress_telphone}}</label>
  24. <label class="default" v-if="daddress_info.daddress_isdefault">默认</label>
  25. </view>
  26. <view class="div desc address-text">{{daddress_info.area_info}}{{daddress_info.daddress_detail}}</view>
  27. </view>
  28. </view>
  29. </flex-line>
  30. <view v-else class="div unselected-wrapper">
  31. <label class="desc">您还没有发货地址,点击这里添加。</label>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="div cart-subtotal">
  36. <view class="div" @click="showPopup('popupExpress')">
  37. <flex-line class="menu-item" :is-link="true" :show-border="true"><text class="span line-name">物流公司</text><text class="span" slot="right">{{express_name}}</text></flex-line>
  38. </view>
  39. <view class="div message" v-if="shipping_express_id!=0">
  40. <flex-line class="field-line" :show-border="true"><text class="span field-name">物流单号</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="shipping_code" /></view></flex-line>
  41. </view>
  42. </view>
  43. <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large" @click="submit">提交</view></view>
  44. </view>
  45. <uni-popup background-color="#fff" ref="popupExpress" type="right" >
  46. <view :style="'width:'+screenWidth+'px'" class="common-popup-wrapper">
  47. <view class="div common-header-wrap">
  48. <view :style="'height:'+navHeight+'px'"></view>
  49. <view class="common-header-holder"></view>
  50. <view class="common-header-fixed">
  51. <title-header />
  52. <uni-nav-bar title="物流公司" class="common-header" left-icon="back" @clickLeft="hidePopup('popupExpress')">
  53. <view class="div common-btn btn" slot="right" @click="setExpress(0,'无需物流')">无需物流</view>
  54. </uni-nav-bar>
  55. </view>
  56. </view>
  57. <view class="div common-popup-content">
  58. <scroll-view style="position: absolute;top:0;right:0;left:0;bottom:0" scroll-y="true" :scroll-into-view="letter">
  59. <view class="div input-wrapper">
  60. <input class="input" ref="input" type="text" v-model="keyword" placeholder="输入关键词" @keydown.enter="searchExpress()"/>
  61. </view>
  62. <view class="div" v-if="!keyword || !resultList">
  63. <view class="div select-wrapper" v-if="my_express && my_express.length">
  64. <view class="div title">我的物流</view>
  65. <view class="div content">
  66. <view class="div item" v-for="(item,index) in my_express" :key="index" @click="setExpress(item.express_id,item.express_name)"><text class="span text">{{item.express_name}}</text></view>
  67. </view>
  68. </view>
  69. <view class="div select-wrapper" v-if="hot_express && hot_express.length">
  70. <view class="div title">常用物流</view>
  71. <view class="div content">
  72. <view class="div item" v-for="(item,index) in hot_express" :key="index" @click="setExpress(item.express_id,item.express_name)"><text class="span text">{{item.express_name}}</text></view>
  73. </view>
  74. </view>
  75. <view class="div sort-list">
  76. <view class="div" v-for="(group,index) in all_express" :key="index">
  77. <view class="div letter" :id="group.letter">{{group.letter}}</view>
  78. <view class="div content">
  79. <view class="div item" v-for="(item,key) in group.list" :key="key" @click="setExpress(item.express_id,item.express_name)">{{item.express_name}}</view>
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="div" v-else>
  85. <view class="div sort-list">
  86. <view class="div content" v-if="resultList.length">
  87. <view class="div item" v-for="(item,key) in resultList" :key="key" @click="setExpress(item.express_id,item.express_name)">{{item.express_name}}</view>
  88. </view>
  89. <empty-record v-else></empty-record>
  90. </view>
  91. </view>
  92. <view class="div nav-list" v-if="!keyword || !resultList">
  93. <view class="div item" v-for="(item,index) in all_express" :key="index" @click="scrollTo(item.letter)">{{item.letter}}</view>
  94. </view>
  95. </scroll-view>
  96. </view>
  97. </view>
  98. </uni-popup>
  99. </view>
  100. </seller-base>
  101. </template>
  102. <script>
  103. import {getFontSize} from '@/util/common'
  104. import TitleHeader from '../../TitleHeader'
  105. import { urlencode } from '@/util/common'
  106. import SellerBase from '../SellerBase'
  107. import { getExpressList, getExpressInfo } from '../../../api/sellerExpress'
  108. import { sendOrder } from '../../../api/sellerOrder'
  109. import EmptyRecord from '../../EmptyRecord'
  110. import flexLine from '../../flexLine'
  111. export default {
  112. components:{
  113. TitleHeader,
  114. SellerBase,
  115. flexLine,
  116. EmptyRecord
  117. },
  118. name: 'SellerOrderSend',
  119. data(){
  120. return {
  121. letter:'',
  122. navHeight: 0,
  123. screenWidth:0,
  124. keyword: '',
  125. order_id: 0,
  126. daddress_info: false,
  127. shipping_code: '',
  128. shipping_express_id: 0,
  129. express_name: '无需物流',
  130. all_express: [],
  131. hot_express: [],
  132. my_express: [],
  133. resultList: false
  134. }
  135. },
  136. computed:{
  137. fontSize(){
  138. return getFontSize()
  139. },
  140. },
  141. onLoad: function (option) {
  142. this.order_id = option.order_id
  143. },
  144. onShow(){
  145. getExpressInfo(this.order_id).then(res => {
  146. this.daddress_info = res.result.daddress_info
  147. }).catch((error)=> {
  148. uni.showToast({icon:'none',title: error.message})
  149. if (error.code == '12002') {
  150. this.goAddress()
  151. }
  152. })
  153. getExpressList(this.order_id).then(res => {
  154. this.all_express = res.result.all_express
  155. this.my_express = res.result.my_express
  156. this.hot_express = res.result.hot_express
  157. }).catch((error)=> {
  158. uni.showToast({icon:'none',title: error.message})
  159. })
  160. },
  161. mounted(){
  162. // #ifdef MP-WEIXIN
  163. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  164. // #endif
  165. this.screenWidth=uni.getSystemInfoSync().screenWidth
  166. },
  167. methods:{
  168. showPopup(id){
  169. this.$refs[id].open()
  170. },
  171. hidePopup(id){
  172. this.$refs[id].close()
  173. },
  174. goBack(){uni.navigateBack({delta:1})},
  175. setExpress (id, name) {
  176. this.shipping_express_id = id
  177. this.express_name = name
  178. this.hidePopup('popupExpress')
  179. },
  180. scrollTo (str) {
  181. this.letter=str
  182. },
  183. searchExpress () {
  184. if (!this.keyword) {
  185. this.resultList = false
  186. } else {
  187. var resultList = []
  188. for (var i in this.all_express) {
  189. for (var j in this.all_express[i].list) {
  190. var str = this.all_express[i].list[j].express_name
  191. if (str.search(this.keyword) != -1) {
  192. resultList.push(this.all_express[i].list[j])
  193. }
  194. }
  195. }
  196. this.resultList = resultList
  197. }
  198. },
  199. goAddress () {
  200. if (this.daddress_info) {
  201. uni.navigateTo({url:'/pages/seller/address/AddressList'})
  202. } else {
  203. uni.navigateTo({url:'/pages/seller/address/AddressForm'+'?'+urlencode({
  204. action: 'add',
  205. isFromCheckout: true,
  206. goBackLevel: -1
  207. })})
  208. }
  209. },
  210. submit () {
  211. if (this.shipping_express_id == 0) {
  212. this.shipping_express_id = ''
  213. }
  214. if (!this.daddress_info) {
  215. uni.showToast({icon:'none',title: '请先添加发货地址'})
  216. return
  217. }
  218. if (this.shipping_express_id != '' && this.shipping_code == '') {
  219. uni.showToast({icon:'none',title: '请先填写物流单号'})
  220. return
  221. }
  222. sendOrder(this.order_id, this.shipping_express_id, this.shipping_code, this.daddress_info.daddress_id).then(res => {
  223. uni.showToast({icon:'none',title: res.message})
  224. uni.navigateBack({delta:1})
  225. }).catch(function (error) {
  226. uni.showToast({icon:'none',title: error.message})
  227. })
  228. }
  229. }
  230. }
  231. </script>
  232. <style lang="scss" scoped>
  233. .common-header{
  234. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  235. }
  236. .main-content{background: #fff;padding:0 $pageSpace}
  237. .daddress_info{display: flex;
  238. .line{display: flex;
  239. .line-content{flex:1}
  240. }
  241. .top-wrapper {
  242. flex: 1;
  243. display: flex;
  244. flex-direction: row;
  245. justify-content: flex-start;
  246. align-items: center;
  247. background-color: #fff;
  248. }
  249. .title-wrapper {
  250. height: 1rem;
  251. display: flex;
  252. flex-direction: row;
  253. justify-content: flex-start;
  254. align-items: center;
  255. }
  256. .icon {
  257. font-size:$h1;
  258. margin-right: .2rem;
  259. color:$primaryColor
  260. }
  261. .title {
  262. }
  263. .default {
  264. width: 1.4rem;
  265. margin-left: 0.5rem;
  266. margin-right: 0.5rem;
  267. border: 1px solid #e93b3d;
  268. color: $primaryColor;
  269. font-size:$h6;
  270. text-align: center;
  271. border-radius: 0.1rem;
  272. }
  273. .desc {
  274. color: $descTextColor;
  275. font-size:$subFontSize;
  276. }
  277. .address-text {
  278. margin-top: .3rem;
  279. font-weight: normal;
  280. }
  281. .selected-wrapper{
  282. flex: 1;
  283. padding:1rem 0;
  284. }
  285. .unselected-wrapper {
  286. flex: 1;
  287. display: flex;
  288. flex-direction: column;
  289. justify-content: center;
  290. align-items: center;
  291. padding:2rem 0;
  292. }
  293. .indicator {
  294. height: 0.6rem;
  295. margin-left: 0.5rem;
  296. margin-right: $pageSpace;
  297. }
  298. .line-wrapper {
  299. background:#eee;
  300. // position: relative;
  301. left: 0;
  302. right: 0;
  303. bottom: 0;
  304. width: 100%;
  305. height: 0.1rem;
  306. }
  307. }
  308. .nav-list{position: fixed;right:0;top:5.5rem;font-size:$fontSize;text-align: center;bottom:4rem;
  309. .item{height: 4.347826%;width:1rem;}
  310. }
  311. .input-wrapper{padding:1rem;position:relative;font-size:$subFontSize;text-align: center;
  312. .placeholder{position: absolute;top:1rem;left:0;width:100%;color:#999;line-height: 1.5rem;}
  313. .input{width:100%;height: 1.5rem;line-height: 1.5rem;border-radius: 1.5rem;border:1px solid #e1e1e1;text-align: center;}
  314. }
  315. .select-wrapper{
  316. .title{padding:1rem;font-size:$subFontSize;color:#666;padding-top:0}
  317. .content{overflow:hidden;padding:0 .5rem;
  318. .item{float:left;width:25%;padding:0 .5rem;box-sizing:border-box;font-size:$subFontSize;height:1.5rem;line-height:1.5rem;margin-bottom:1rem;
  319. .text{border:1px solid #e1e1e1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block;border-radius:.2rem;text-align:center;background:#fff;
  320. }
  321. }
  322. }
  323. }
  324. .sort-list{padding:0 1rem;font-size:$subFontSize;
  325. .letter{}
  326. .content{padding-bottom:1rem;
  327. .item{line-height:2rem;border-bottom:1px solid #e1e1e1}
  328. }
  329. }
  330. </style>