checkOut.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="page-content">
  3. <view class="content">
  4. <u-field
  5. class="field-item"
  6. :value="store.name"
  7. disabled
  8. input-align="right"
  9. label="收取门店"
  10. >
  11. </u-field>
  12. <u-field
  13. v-model="remarks"
  14. label="备注"
  15. input-align="right"
  16. auto-height
  17. :maxlength="10"
  18. placeholder="请填写备注(最多10个字符)"
  19. >
  20. </u-field>
  21. <view class="num-cont">
  22. <text class="u-required">支付数量</text>
  23. <view class="num-input">
  24. <u-input v-model="number" input-align="right" type="number" placeholder="请输入数量" />
  25. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="pay-btn">
  30. <view class="total">
  31. <text>{{number||0}}</text>
  32. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  33. </view>
  34. <u-button :custom-style="btnStyle" @click="handlePay" type="error" >确认支付</u-button>
  35. </view>
  36. <!-- 确认支付弹窗 -->
  37. <u-popup mode="center" closeable @close="closeModal" v-model="showPayModal" width="600rpx" >
  38. <view class="slot-content">
  39. <view>请输入支付密码</view>
  40. <view class="text-cont">
  41. <view>
  42. <text>收取门店:</text>
  43. <text>{{store.name||'--'}}</text>
  44. </view>
  45. <view class="num-text">
  46. <text>支付数量:</text>
  47. <view>
  48. <text class="num-big">{{number}}</text>
  49. <u-image mode="scaleToFill" width="40rpx" height="40rpx" src="/static/ledou.png"></u-image>
  50. </view>
  51. </view>
  52. <view>
  53. <text>备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</text>
  54. <text>{{remarks||'--'}}</text>
  55. </view>
  56. </view>
  57. <view class="footer">
  58. <input v-model="password"
  59. type="password"
  60. placeholder="请输入支付密码"
  61. :maxlength="30"
  62. @confirm="confirm"
  63. />
  64. </view>
  65. <view class="fot-btn">
  66. <u-button :custom-style="btnStyle" @click="confirm" type="error" >确认支付</u-button>
  67. </view>
  68. </view>
  69. </u-popup>
  70. <!-- 提示用户设置支付密码 -->
  71. <u-modal v-model="showSetPswModal"
  72. content="请先设置支付密码,才能使用乐豆"
  73. show-cancel-button
  74. confirm-text="去设置"
  75. cancel-text="暂时放弃"
  76. @confirm="toSetPwd"
  77. @cancel="showSetPswModal=false"
  78. ></u-modal>
  79. </view>
  80. </template>
  81. <script>
  82. import { sellerReceive,sellerFindByPartnerNo } from '@/api/user.js'
  83. import { existPayPwd } from '@/api/order.js'
  84. export default{
  85. data() {
  86. return {
  87. btnStyle: {
  88. backgroundColor : '#07c160'
  89. },
  90. showSetPswModal: false,
  91. store: null, // 门店信息
  92. remarks: '', // 备注
  93. number: '', // 支付数量
  94. showPayModal: false, // 支付弹窗
  95. password: '', // 支付密码
  96. partnerNo: '', // 销售商编号
  97. currentGold: 0 //用户当前拥有乐豆数
  98. }
  99. },
  100. onLoad(opts) {
  101. this.currentGold = this.$store.state.vuex_userData.currentGold
  102. console.log(this.currentGold,'currentGold')
  103. console.log(opts)
  104. this.partnerNo = opts.scene
  105. // 查询销售商信息
  106. sellerFindByPartnerNo({officialPartnerNo: this.partnerNo}).then(res => {
  107. if(res.status == 200){
  108. this.store = res.data
  109. } else {
  110. setTimeout(()=>{
  111. uni.navigateBack()
  112. },500)
  113. }
  114. })
  115. },
  116. methods: {
  117. // 跳转到设置支付密码页
  118. toSetPwd () {
  119. uni.navigateTo({
  120. url:"/pages/userCenter/userInfo/smsVerification"
  121. })
  122. },
  123. // 确认支付
  124. handlePay() {
  125. if (!this.number) {
  126. uni.showToast({
  127. title: '请输入支付数量',
  128. icon: 'none'
  129. })
  130. } else {
  131. if (this.number>this.currentGold) {
  132. uni.showToast({
  133. title: '您当前余额不足!',
  134. icon: 'none'
  135. })
  136. return false
  137. }
  138. existPayPwd().then(res => {
  139. console.log(res,'rrrrrr')
  140. if(res.status == 200) {
  141. // 设置过支付密码,输入密码
  142. if(res.data) {
  143. this.showPayModal = true
  144. } else {
  145. // 没设置过支付密码,提示设置密码
  146. this.showSetPswModal = true
  147. }
  148. }
  149. })
  150. }
  151. },
  152. // 关闭弹窗
  153. closeModal() {
  154. this.showPayModal = false
  155. this.password = ''
  156. },
  157. // 输入密码完成 支付
  158. confirm(e) {
  159. if(this.password == ''){
  160. uni.showToast({
  161. title: '请输入支付密码',
  162. icon: 'none'
  163. })
  164. return
  165. }
  166. let data = {
  167. "payPassword": this.password,
  168. "changeNum": this.number,
  169. "remarks": this.remarks,
  170. "officialPartnerNo": this.partnerNo
  171. }
  172. sellerReceive(data).then(res => {
  173. console.log(res)
  174. if(res.status == 200){
  175. uni.redirectTo({
  176. url: '/pages/checkOut/checkFinish?num='+this.number
  177. })
  178. } else {
  179. uni.showToast({
  180. icon: 'none',
  181. title: res.message
  182. })
  183. }
  184. })
  185. }
  186. },
  187. }
  188. </script>
  189. <style lang="less">
  190. page{
  191. height: 100%;
  192. }
  193. .page-content{
  194. width: 100%;
  195. height: 100%;
  196. padding: 20upx;
  197. background-color: #f8f8f8;
  198. .content{
  199. background-color: #fff;
  200. }
  201. .num-cont{
  202. width: 100%;
  203. padding: 16upx;
  204. display: flex;
  205. align-items: center;
  206. justify-content: space-between;
  207. .num-input{
  208. display: flex;
  209. align-items: center;
  210. justify-content: center;
  211. >u-input {
  212. width: 300upx;
  213. }
  214. }
  215. }
  216. .pay-btn{
  217. padding: 0 30upx;
  218. .total {
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. font-size: 48upx;
  223. font-weight: 600;
  224. color: red;
  225. padding: 60upx 0;
  226. }
  227. }
  228. }
  229. .slot-content{
  230. padding: 30upx 0;
  231. font-size: 32upx;
  232. display: flex;
  233. flex-direction: column;
  234. align-items: center;
  235. justify-content: space-between;
  236. .text-cont{
  237. width: 100%;
  238. margin-top: 20upx;
  239. border-bottom: 1px solid #F8F8F8;
  240. >view {
  241. padding: 10upx 40upx;
  242. display: flex;
  243. >text{
  244. &:last-child {
  245. flex: 1;
  246. padding-left: 30upx;
  247. }
  248. }
  249. .num-big{
  250. font-size: 36upx;
  251. color: red;
  252. padding-left: 30upx;
  253. font-weight: 600;
  254. }
  255. }
  256. .num-text{
  257. align-items: center;
  258. >view {
  259. display: flex;
  260. align-items: center;
  261. }
  262. }
  263. }
  264. .footer{
  265. width: 80%;
  266. border-bottom: 1px solid #b1b1b1;
  267. >input {
  268. text-align: center;
  269. padding: 10upx 0;
  270. }
  271. }
  272. .fot-btn{
  273. margin-top: 30upx;
  274. }
  275. }
  276. </style>