index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div class="container">
  3. <el-card class="in">
  4. <el-tabs type="card">
  5. <el-tab-pane label="下单">
  6. <div class="pd-30">
  7. <el-form
  8. :model="ruleForm"
  9. ref="ruleForm"
  10. label-width="100px"
  11. class="demo-ruleForm"
  12. style="width: 1300px;"
  13. status-icon
  14. >
  15. <el-form-item label="outtradeno">
  16. <el-row>
  17. <el-col :span="8">
  18. <el-input :disabled="disabled1" v-model="ruleForm.outtradeno" clearable></el-input>
  19. </el-col>
  20. <el-col :span="12">
  21. <div class="grid-content bg-purple-light">例:1597813670074370</div>
  22. </el-col>
  23. </el-row>
  24. </el-form-item>
  25. <el-form-item label="shippingaddr">
  26. <el-row>
  27. <el-col :span="8">
  28. <el-input
  29. :disabled="disabled2"
  30. type="textarea"
  31. v-model="ruleForm.shippingaddr"
  32. clearable
  33. placeholder="地址"
  34. ></el-input>
  35. </el-col>
  36. <el-col :span="16">
  37. <div
  38. class="grid-content bg-purple-light"
  39. >例:上海市;上海市;徐汇区;中山西路2025号永升大厦1210;200030;121.42771;31.18259;187*******12;王</div>
  40. </el-col>
  41. </el-row>
  42. </el-form-item>
  43. <el-form-item label="shopid">
  44. <el-row>
  45. <el-col :span="8">
  46. <el-input
  47. :disabled="disabled2"
  48. v-model="ruleForm.shopid"
  49. clearable
  50. placeholder="门店id"
  51. ></el-input>
  52. </el-col>
  53. <el-col :span="12">
  54. <div class="grid-content bg-purple-light"></div>
  55. </el-col>
  56. </el-row>
  57. </el-form-item>
  58. <el-form-item label="totalfee">
  59. <el-row>
  60. <el-col :span="8">
  61. <el-input
  62. :disabled="disabled2"
  63. type="textarea"
  64. v-model="ruleForm.totalfee"
  65. clearable
  66. placeholder="总价"
  67. ></el-input>
  68. </el-col>
  69. <el-col :span="12">
  70. <div class="grid-content bg-purple-light">例: 1900</div>
  71. </el-col>
  72. </el-row>
  73. </el-form-item>
  74. <el-form-item label="products">
  75. <el-row>
  76. <el-col :span="8">
  77. <el-input
  78. :disabled="disabled2"
  79. type="textarea"
  80. v-model="ruleForm.products"
  81. clearable
  82. placeholder="商品"
  83. ></el-input>
  84. </el-col>
  85. <el-col :span="12">
  86. <div class="grid-content bg-purple-light">例: 拿铁(冰) x 1</div>
  87. </el-col>
  88. </el-row>
  89. </el-form-item>
  90. <el-row>
  91. <el-col :span="24">
  92. <div class="tip bg-purple">
  93. 注:下单成功后,请到
  94. <a
  95. href="https://peisong.meituan.com/open/index"
  96. target="_blank"
  97. rel="noopener noreferrer"
  98. >美团配送开放平台</a>查看配送信息
  99. </div>
  100. </el-col>
  101. </el-row>
  102. <el-form-item>
  103. <el-button
  104. type="primary"
  105. @click="submitForm('ruleForm')"
  106. :loading="goShopLoading"
  107. >下 单</el-button>
  108. <el-button @click="resetForm('ruleForm')">重 置</el-button>
  109. </el-form-item>
  110. </el-form>
  111. </div>
  112. </el-tab-pane>
  113. <el-tab-pane label="正常下单">正常下单</el-tab-pane>
  114. </el-tabs>
  115. </el-card>
  116. </div>
  117. </template>
  118. <script>
  119. import { shopping } from "@/api/order";
  120. var that;
  121. export default {
  122. name: "Shopping",
  123. data() {
  124. return {
  125. ruleForm: {
  126. shippingaddr: "",
  127. shopid: "",
  128. totalfee: "",
  129. products: "",
  130. outtradeno: "",
  131. },
  132. goShopLoading: false,
  133. disabled1: false,
  134. disabled2: false,
  135. };
  136. },
  137. beforeMount() {
  138. that = this;
  139. },
  140. watch: {
  141. ruleForm: {
  142. deep: true,
  143. handler: function (newVal) {
  144. console.log(newVal);
  145. if (!!newVal.outtradeno) {
  146. console.log(111);
  147. this.disabled2 = true;
  148. } else {
  149. this.disabled2 = false;
  150. }
  151. if (
  152. newVal.shippingaddr ||
  153. newVal.shopid ||
  154. newVal.totalfee ||
  155. newVal.products
  156. ) {
  157. this.disabled1 = true;
  158. } else {
  159. this.disabled1 = false;
  160. }
  161. },
  162. },
  163. },
  164. methods: {
  165. reset() {
  166. this.ruleForm = {
  167. shippingaddr: "",
  168. shopid: "",
  169. totalfee: "",
  170. products: "",
  171. outtradeno: "",
  172. };
  173. this.disabled1 = false;
  174. this.disabled2 = false;
  175. this.goShopLoading = false;
  176. },
  177. submitForm(formName) {
  178. this.goShopLoading = true;
  179. let params = {};
  180. if (!this.disabled1) {
  181. params.outtradeno = this.ruleForm.outtradeno;
  182. } else if (!this.disabled2) {
  183. params.shippingaddr = this.ruleForm.shippingaddr;
  184. params.shopid = this.ruleForm.shopid - 0;
  185. params.totalfee = this.ruleForm.totalfee - 0;
  186. params.products = this.ruleForm.products;
  187. }
  188. shopping(params)
  189. .then((res) => {
  190. this.$message({
  191. message: "下单成功!",
  192. type: "success",
  193. });
  194. this.reset();
  195. })
  196. .catch((err) => {
  197. // this.$message.error("输入的信息有误!");
  198. this.goShopLoading = false;
  199. });
  200. },
  201. resetForm(formName) {
  202. this.$refs[formName].resetFields();
  203. },
  204. },
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. .container {
  209. box-sizing: border-box;
  210. padding: 20px;
  211. }
  212. .pd-30 {
  213. padding: 30px;
  214. }
  215. .bg-purple-light {
  216. color: #999;
  217. padding: 0 20px;
  218. }
  219. .tip {
  220. font-size: 14px;
  221. color: #999;
  222. padding-left: 100px;
  223. padding-bottom: 30px;
  224. }
  225. .tip a {
  226. color: #fecb2e;
  227. text-decoration: underline;
  228. }
  229. </style>