ToBuy.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="toBuy-wrap">
  3. <div class="baseInfo-wrap">
  4. <img :src="goodMess.coverImg" />
  5. <div>
  6. <h5>{{goodMess.title}}</h5>
  7. <p>{{goodMess.produce}}</p>
  8. <span>{{goodMess.price}}</span>
  9. </div>
  10. </div>
  11. <div class="flow-wrap">
  12. <el-steps :active="active" finish-status="success">
  13. <el-step title="订单选择"></el-step>
  14. <el-step title="确认支付"></el-step>
  15. <el-step title="订单完成"></el-step>
  16. </el-steps>
  17. <div class="flow-content" v-show="active==0">
  18. <el-form label-position="right" label-width="80px">
  19. <el-form-item v-for="(tag,index) in tagList" :label="tag.type" :key="index">
  20. <el-select v-model="orderForm[index].item.name" placeholder="请选择个性化分类" @change="selectChange($event,index)">
  21. <el-option v-for="(list,index) in tag.list" :value="list.name" :key="index">{{list.name}}</el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="价格">
  25. <el-input v-model="price" disabled></el-input>
  26. </el-form-item>
  27. </el-form>
  28. <el-button class="confrimBtn" @click="toConfrimOrder">确认订单</el-button>
  29. </div>
  30. <div class="flow-content" v-show="active==1">
  31. <div v-for="(item,index) in orderForm" class="confirmPayment">
  32. <p>{{item.type}}:{{item.item.name}}</p>
  33. <p>价格:<span>{{item.item.price}}</span></p>
  34. </div>
  35. <div class="confirmPayment">
  36. <p></p>
  37. <p>总计:<span>{{price}}</span></p>
  38. </div>
  39. <el-button class="confrimBtn price" @click="toConfirmPayment">确认支付</el-button>
  40. </div>
  41. <div class="flow-content orderCompletion" v-show="active>=2">
  42. <img src="../../assets/images/admin/complate.png" />
  43. <p>订单已完成!可在“我的订单”中查看</p>
  44. <el-button class="confrimBtn price" @click="toShow" v-show="active==2">立即评价</el-button>
  45. </div>
  46. </div>
  47. <el-dialog title="我的评价" :visible.sync="dialogTableVisible" :show-close="false">
  48. <div class="dialogheader">
  49. <el-form label-position="right" label-width="80px">
  50. <el-form-item label="评价内容">
  51. <el-input type="textarea" v-model="evaluate"></el-input>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-button type="primary" @click="toSubmitEvaluation">提交</el-button>
  55. <el-button @click="toCancel">取消</el-button>
  56. </el-form-item>
  57. </el-form>
  58. </div>
  59. </el-dialog>
  60. </div>
  61. </template>
  62. <script>
  63. export default{
  64. data(){
  65. return{
  66. goodMess:{},
  67. active: 0,
  68. tagList:[],
  69. orderForm:[],
  70. price:0,
  71. dialogTableVisible:false,
  72. evaluate:"",
  73. id:"",
  74. }
  75. },
  76. mounted(){
  77. this.getGoodMess();
  78. },
  79. methods:{
  80. getGoodMess(){
  81. let param = {
  82. shopId:this.$route.query.shopId,
  83. goodId:this.$route.query.id
  84. }
  85. this.axios.post(this.Api.getGoodMess,param).then((res)=>{
  86. this.goodMess=res.data;
  87. this.tagList=res.data.tags;
  88. for(var i=0,length=this.tagList.length;i<length;i++){
  89. let tag={
  90. type:this.tagList[i].type,
  91. item:{
  92. name:"",
  93. price:0
  94. }
  95. }
  96. this.orderForm.push(tag);
  97. }
  98. }).catch((err)=>{
  99. console.log("getGoodMess:"+err);
  100. });
  101. },
  102. next() {
  103. if (this.active++ > 2) this.active = 0;
  104. },
  105. toConfrimOrder(){
  106. var index = this.orderForm.findIndex((value,index,arr)=>{
  107. return value.item.name=="";
  108. })
  109. if(index==-1){
  110. this.next();
  111. }else{
  112. this.$message.error('请填写完整信息');
  113. }
  114. },
  115. selectChange(value,index){
  116. var index2 = this.tagList[index].list.findIndex((value1,index,arr)=>{
  117. return value1.name==value;
  118. })
  119. this.orderForm[index].item.price=this.tagList[index].list[index2].price;
  120. console.log(this.orderForm)
  121. this.calcPrice();
  122. },
  123. calcPrice(){
  124. this.price=0;
  125. for(var i=0,length=this.orderForm.length;i<length;i++){
  126. this.price+=this.orderForm[i].item.price;
  127. }
  128. },
  129. toConfirmPayment(){
  130. let param = {
  131. shopId:this.$route.query.shopId,
  132. goodId:this.$route.query.id,
  133. buyerId:this.$store.state.userMess.id,
  134. madeTags:this.orderForm,
  135. }
  136. this.axios.post(this.Api.paySuccess,param).then((res)=>{
  137. console.log(res.data)
  138. if(res.data.code==200){
  139. this.id=res.data.id;
  140. this.next();
  141. }
  142. }).catch((err)=>{
  143. console.log("toConfirmPayment:"+err);
  144. });
  145. },
  146. toCancel(){
  147. this.dialogTableVisible=false;
  148. this.evaluate="";
  149. },
  150. toShow(){
  151. this.dialogTableVisible=true;
  152. },
  153. toSubmitEvaluation(){
  154. if(this.evaluate==""){
  155. this.$message.error('请输入评价内容');
  156. return;
  157. }
  158. let param={
  159. buyerId:this.$store.state.userMess.id,
  160. shopId:this.$route.query.shopId,
  161. goodId:this.$route.query.id,
  162. id:this.id,
  163. comment:this.evaluate
  164. }
  165. this.axios.post(this.Api.submitEvaluation,param).then((res)=>{
  166. console.log(res.data)
  167. if(res.data.code==200){
  168. this.next();
  169. this.toCancel();
  170. }
  171. }).catch((err)=>{
  172. console.log("toSubmitEvaluation:"+err);
  173. });
  174. }
  175. }
  176. }
  177. </script>
  178. <style scoped>
  179. .toBuy-wrap{
  180. width: 100%;
  181. padding: 0 20px;
  182. }
  183. .baseInfo-wrap{
  184. width: 100%;
  185. height: 300px;
  186. margin-top: 20px;
  187. background-color: #fff;
  188. border-left: 6px solid #3eb983;
  189. padding: 20px 20px 20px 13px;
  190. }
  191. .baseInfo-wrap img{
  192. display: block;
  193. float: left;
  194. width: 260px;
  195. height: 260px;
  196. }
  197. .baseInfo-wrap div{
  198. float: left;
  199. padding-left: 20px;
  200. text-align: left;
  201. width: calc(100% - 260px);
  202. }
  203. .baseInfo-wrap h5{
  204. font-size: 30px;
  205. margin-bottom: 10px;
  206. }
  207. .baseInfo-wrap p{
  208. font-size: 16px;
  209. color: #666;
  210. width: 100%;
  211. height: 100px;
  212. }
  213. .baseInfo-wrap span{
  214. font-size: 30px;
  215. color: #EA6A69;
  216. line-height: 65px;
  217. display: block;
  218. }
  219. .flow-wrap{
  220. width: 100%;
  221. height: auto;
  222. margin-top: 20px;
  223. background-color: #fff;
  224. padding: 20px;
  225. }
  226. .flow-content{
  227. width: 600px;
  228. margin: 40px auto 0;
  229. }
  230. .confrimBtn{
  231. background-color: #3eb983;
  232. border-color: #3eb983;
  233. color: #fff;
  234. padding: 10px 40px;
  235. }
  236. .confirmPayment{
  237. display: flex;
  238. justify-content: space-around;
  239. font-size: 20px;
  240. line-height: 40px;
  241. }
  242. .confirmPayment p{
  243. width: 200px;
  244. }
  245. .confirmPayment span{
  246. color: #EA6A69;
  247. }
  248. .price{
  249. margin-top: 20px;
  250. }
  251. .orderCompletion{
  252. text-align: center;
  253. }
  254. .orderCompletion img{
  255. width: 180px;
  256. }
  257. .orderCompletion p{
  258. color: #3eb983;
  259. font-size: 18px;
  260. line-height: 30px;
  261. }
  262. </style>
  263. <style>
  264. .el-step__head{
  265. text-align: left;
  266. }
  267. .flow-wrap .el-input.is-disabled .el-input__inner{
  268. color: #EA6A69;
  269. }
  270. .el-dialog{
  271. width: 500px;
  272. /*height: 280px;*/
  273. border-radius: 6px;
  274. text-align: left;
  275. }
  276. .el-dialog__header{
  277. padding: 20px 30px 0 40px;
  278. }
  279. .el-dialog__body{
  280. padding: 20px 30px;
  281. }
  282. .dialogheader{
  283. width: 100%;
  284. /*height: 60px;*/
  285. }
  286. .dialogheader p{
  287. width: 360px;
  288. height: 30px;
  289. line-height: 30px;
  290. margin-top: 10px;
  291. border:1px solid #3eb983;
  292. border-radius: 6px;
  293. text-align: left;
  294. padding-left: 10px;
  295. margin-left: 60px;
  296. }
  297. .dialogheader p input{
  298. height: 24px;
  299. line-height: 24px;
  300. border:0;
  301. margin-left: 20px;
  302. }
  303. .dialogheader .button{
  304. background: #3eb983;
  305. color: #fff;
  306. text-align: center;
  307. margin-top: 40px;
  308. cursor: pointer;
  309. }
  310. .dialogheader .el-button{
  311. width: 173px;
  312. padding: 10px 0;
  313. }
  314. .dialogheader .el-form-item{
  315. margin-bottom: 15px;
  316. }
  317. .dialogheader .el-button+.el-button{
  318. margin-left: 0;
  319. }
  320. .dialogheader .el-button--primary{
  321. background-color: #3eb983;
  322. border-color: #3eb983;
  323. }
  324. .dialogheader .el-button--primary:hover{
  325. background-color: #3eb983;
  326. border-color: #3eb983;
  327. }
  328. .dialogheader .el-button--default{
  329. background-color: #bfcbd9;
  330. color: #fff;
  331. }
  332. .dialogheader .el-button--default:hover{
  333. background-color: #bfcbd9;
  334. border-color: #bfcbd9;
  335. color: #fff;
  336. }
  337. .el-step__head.is-success{
  338. color: #3eb983;
  339. border-color: #3eb983;
  340. }
  341. .el-step__title.is-success{
  342. color: #3eb983;
  343. }
  344. </style>