send.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view>
  3. <view class="container book-main">
  4. <view class="form-box">
  5. <view class="form-box-label">服务开始时间<text class="text-red">*</text></view>
  6. <view class="form-box-content">
  7. <view class="form-box-content" @click="selectStart">
  8. <view class="form-box-content-text" v-if="!start">请选择</view>
  9. <view class="form-box-content-text" v-if="start">{{start}}</view>
  10. <image src="../../images/xiangyou-xiao.png"></image>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="form-box">
  15. <view class="form-box-label">选择服务</view>
  16. <view class="form-box-content" @click="selectCate">
  17. <view class="form-box-content-text" v-if="!cate.title">请选择</view>
  18. <view class="form-box-content-text" v-if="cate.title">{{cate.title}}</view>
  19. <image src="../../images/xiangyou-xiao.png"></image>
  20. </view>
  21. </view>
  22. <view class="form-box">
  23. <view class="form-box-label">价格(/人/天)<text class="text-red">*</text></view>
  24. <view class="form-box-content">
  25. <input type="text" placeholder="请填写" v-model="price" />
  26. </view>
  27. </view>
  28. <view class="form-box">
  29. <view class="form-box-label">选择护工</view>
  30. <view class="form-box-content" @click="goSelectWorker">
  31. <view class="form-box-content-text" v-if="!unames">请选择</view>
  32. <view class="form-box-content-text" v-if="unames">{{unames}}</view>
  33. <image src="../../images/xiangyou-xiao.png"></image>
  34. </view>
  35. </view>
  36. <view class="form-box form-box2">
  37. <view class="form-box-label">备注</view>
  38. <view class="form-box-textarea">
  39. <textarea style="height:120rpx;" v-model="remark" placeholder="请填写" />
  40. </view>
  41. </view>
  42. <view class="book-btn" @click="saveBtn()">提交</view>
  43. </view>
  44. <cpicker v-if="cates.length > 0" :list="cates" :show.sync="cateShow" :did="cate.id" @confirm="selectedCateVal"></cpicker>
  45. <w-picker
  46. :visible.sync="startVisible"
  47. mode="date"
  48. startYear="2021"
  49. endYear="5000"
  50. themeColor="#FF7576"
  51. :value="start"
  52. :current="true"
  53. fields="minute"
  54. @confirm="onConfirm($event,'date')"
  55. :disabled-after="false"
  56. ref="date"
  57. ></w-picker>
  58. </view>
  59. </template>
  60. <script>
  61. var app = getApp();
  62. import cpicker from "../../components/cpicker/cpicker.vue";
  63. import wpicker from "../../components/w-picker/w-picker.vue";
  64. export default {
  65. components: {
  66. cpicker,
  67. wpicker
  68. },
  69. data() {
  70. return {
  71. flag: false,
  72. start:'',
  73. startVisible:false,
  74. cate: {
  75. id: 0,
  76. title: '',
  77. price: 0,
  78. },
  79. cateShow: false,
  80. cates:[],
  81. remark: '',
  82. price: '',
  83. unames: '',
  84. workers: [],
  85. orderId: 0
  86. }
  87. },
  88. onLoad(option) {
  89. this.orderId = option.orderId;
  90. console.log(option);
  91. },
  92. onShow() {
  93. var that = this;
  94. app.ajaxReadyCallback = res => { //各个接口统一回调方法
  95. var apiname = res.data.apiname;
  96. console.log(res);
  97. if(apiname == 'cate'){
  98. that.cates = res.data.data;
  99. } else if(apiname == 'order'){
  100. uni.navigateBack({
  101. delta: 1
  102. });
  103. }
  104. }
  105. this.getCate();
  106. },
  107. methods: {
  108. getUrlCode (name) {
  109. return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ''])[1].replace(/\+/g, '%20')) || null
  110. },
  111. selectCate(){
  112. this.cateShow = true;
  113. },
  114. selectedCateVal(obj){
  115. console.log(obj)
  116. this.cate = obj;
  117. this.price = obj.price;
  118. },
  119. getCate(){
  120. app.ajaxUnlogin({
  121. url: app.globalData.serverUrl + 'cate/cateList',
  122. type: 'POST',
  123. apiname: 'cate',
  124. });
  125. },
  126. onConfirm(e,type){
  127. this.start = e.result;
  128. },
  129. selectStart(){
  130. this.startVisible = true;
  131. },
  132. goSelectWorker(){
  133. var that = this;
  134. uni.navigateTo({
  135. url: '/pages/order/worker',
  136. events: {
  137. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  138. acceptDataFromOpenedPage: function(data) {
  139. console.log('jieshou:',data)
  140. that.workers = data;
  141. let names = [];
  142. that.workers.forEach((item,index) => {
  143. if(index < 2){
  144. names.push(item.name)
  145. }
  146. });
  147. if(that.workers.length > 2){
  148. that.unames = names.join(',') + '...';
  149. }else{
  150. that.unames = names.join(',');
  151. }
  152. }
  153. },
  154. success: function(res) {
  155. // 通过eventChannel向被打开页面传送数据
  156. res.eventChannel.emit('acceptDataFromOpenerPage', { workers: that.workers })
  157. }
  158. })
  159. },
  160. saveBtn(){
  161. if(!this.start){
  162. uni.showToast({
  163. title: '请选择服务开始时间',
  164. icon: 'none',
  165. duration: 2000
  166. })
  167. return;
  168. }
  169. if(!this.cate.id){
  170. uni.showToast({
  171. title: '请选择服务',
  172. icon: 'none',
  173. duration: 2000
  174. })
  175. return;
  176. }
  177. if(!this.cate.price){
  178. uni.showToast({
  179. title: '请输入价格',
  180. icon: 'none',
  181. duration: 2000
  182. })
  183. return;
  184. }
  185. let uids = [];
  186. this.workers.forEach((item) => {
  187. uids.push(item.id);
  188. })
  189. if(uids.length <= 0){
  190. uni.showToast({
  191. title: '请选择护工',
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. return;
  196. }
  197. let param = {
  198. id: this.orderId,
  199. start: this.start,
  200. remark: this.remark,
  201. cate_id: this.cate.id,
  202. price: this.price,
  203. uids: uids.join(',')
  204. }
  205. app.ajax({
  206. url: app.globalData.serverUrl + 'order/send',
  207. type: 'POST',
  208. apiname: 'order',
  209. data: param
  210. });
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .navbg{
  217. width: 100%;
  218. height: 300rpx;
  219. }
  220. .book-main{
  221. width: 710rpx;
  222. // position: absolute;
  223. // z-index: 10;
  224. // top: 300rpx;
  225. // left: 0;
  226. // bottom: 0;
  227. overflow: auto;
  228. }
  229. .book-btn{
  230. width: 710rpx;
  231. height: 90rpx;
  232. line-height: 90rpx;
  233. background-color: var(--themeColor);
  234. color: #ffffff;
  235. font-size: 34rpx;
  236. font-weight: bold;
  237. text-align: center;
  238. border-radius: 10rpx;
  239. }
  240. </style>