pay.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="content">
  3. <view class="supplyInfo">
  4. <view class="tel flex">
  5. <label>缴费名称:</label>
  6. <input type="text" class="card input" v-model="payInfo.name" disabled/>
  7. </view>
  8. <view class="tel flex">
  9. <label>订单编号:</label>
  10. <input type="text" class="card input" v-model="payInfo.code" disabled/>
  11. </view>
  12. <view class="tel flex">
  13. <label>住宅地址:</label>
  14. <input type="text" class="card input" v-model="payInfo.address" disabled/>
  15. </view>
  16. <view class="tel flex">
  17. <label>户主姓名:</label>
  18. <input type="text" class="card input" v-model="payInfo.owner_name" disabled/>
  19. </view>
  20. <view class="tel flex">
  21. <label>住宅面积:</label>
  22. <input type="text" class="card input" v-model="payInfo.area" disabled/>
  23. </view>
  24. <view class="tel flex">
  25. <label>缴费类型:</label>
  26. <radio-group @change="payChange">
  27. <radio value="1" :checked="payInfo.type!==2" style="margin-right: 30rpx;transform: scale(0.85);">金额</radio>
  28. <radio value="2" :checked="payInfo.type===2" style="transform: scale(0.85);">空置</radio>
  29. </radio-group>
  30. </view>
  31. <view class="tel flex">
  32. <label>缴费金额:</label>
  33. <input type="text" class="card input" id="real_fee" v-model="payInfo.real_fee" disabled/>
  34. </view>
  35. </view>
  36. <button class="submit" @tap="paySubmit">{{payStatus ? '申请开票' : '缴费'}}</button>
  37. <uni-popup ref="popup" :mask-click="false">
  38. <view class="popup-box">
  39. <view>
  40. <view class="popup-title">申请开票</view>
  41. <view class="popup-content-box">
  42. <view class="popup-content">
  43. <view class="popup-type">
  44. <view>开票抬头:</view><input type="text" value="" />
  45. </view>
  46. <view class="popup-type">
  47. <view>备注:</view><input type="text" value="" />
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="popup-footer">
  53. <button class="popup-submit" @click="submitInvocie">提交</button>
  54. </view>
  55. </view>
  56. </uni-popup>
  57. </view>
  58. </template>
  59. <script>
  60. import md5 from "@/common/md5.js";
  61. export default {
  62. data() {
  63. return {
  64. payInfo: {
  65. },
  66. payStatus:0,
  67. };
  68. },
  69. onLoad(option) {
  70. this.getPayDetail(option.id)
  71. },
  72. methods: {
  73. getPayDetail(payId) {
  74. let md5Sign = md5(
  75. "method=" +
  76. "user" +
  77. "&timestamp=" +
  78. getApp().globalData.globalTimestamp +
  79. "&secret=" +
  80. getApp().globalData.secret
  81. );
  82. let url =
  83. getApp().globalData.shareUrl +
  84. "api/api.php" +
  85. "?method=user&source=user&action=get_order_info&timestamp=" +
  86. getApp().globalData.globalTimestamp +
  87. "&sign=" +
  88. md5Sign;
  89. let postData = {
  90. code:payId,
  91. openId: getApp().globalData.open_id,
  92. };
  93. uni.request({
  94. url: url,
  95. method: "POST",
  96. header: {
  97. "content-type": "application/x-www-form-urlencoded",
  98. },
  99. data: postData,
  100. success: (res) => {
  101. if (res.data.code === 200) {
  102. this.payInfo = res.data.data;
  103. this.payInfo.address = this.payInfo.estate_name + this.payInfo.building_name + this.payInfo.unit + this.payInfo.room
  104. } else {
  105. uni.showToast({
  106. title: res.data.msg,
  107. icon: "none",
  108. duration: 2500,
  109. });
  110. }
  111. },
  112. fail: () => {
  113. console.log("连接失败");
  114. },
  115. });
  116. },
  117. payChange(e){
  118. let v = e.detail.value;
  119. if (v == 2)
  120. {
  121. let value = this.payInfo.part_fee - this.payInfo.reduction;
  122. this.payInfo.real_fee = value;
  123. }
  124. else
  125. {
  126. let value = this.payInfo.total_fee - this.payInfo.reduction;
  127. this.payInfo.real_fee = value;
  128. }
  129. this.payInfo.payType = e.detail.value;
  130. },
  131. paySubmit(){
  132. if(this.payStatus){
  133. this.open()
  134. return
  135. }
  136. uni.requestPayment({
  137. provider: 'wxpay',
  138. timeStamp: String(Date.now()),
  139. nonceStr: 'A1B2C3D4E5',
  140. package: 'prepay_id=wx20180101abcdefg',
  141. signType: 'MD5',
  142. paySign: '',
  143. success: function (res) {
  144. console.log('success:' + JSON.stringify(res));
  145. this.payStatus = 1;
  146. },
  147. fail: function (err) {
  148. console.log('fail:' + JSON.stringify(err));
  149. }
  150. });
  151. //支付这里缺少签名参数 还需要后台配合调用微信那边的接口
  152. //参考https://github.com/dcloudio/H5P.Server/tree/master/payment
  153. },
  154. submitInvocie(){
  155. this.closePopup()
  156. },
  157. open() {
  158. this.$refs.popup.open('center')
  159. },
  160. closePopup() {
  161. this.$refs.popup.close()
  162. },
  163. },
  164. };
  165. </script>
  166. <style lang="scss" scoped>
  167. .content {
  168. font-size: 28rpx;
  169. font-weight: 200;
  170. padding: 1% 2%;
  171. .title {
  172. font-size: 30rpx;
  173. margin: 4% 0;
  174. }
  175. label {
  176. display: inline-block;
  177. width: 25%;
  178. vertical-align: middle;
  179. }
  180. .card {
  181. background-color: rgb(248, 247, 247);
  182. border-radius: 10rpx;
  183. }
  184. .flex {
  185. display: flex;
  186. align-items: center;
  187. margin-bottom: 2%;
  188. }
  189. .input {
  190. padding: 0 2%;
  191. margin: 2% 0;
  192. display: inline-block;
  193. width: 80%;
  194. height: 70rpx;
  195. }
  196. .supplyInfo {
  197. border-radius: 40rpx;
  198. padding: 4%;
  199. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  200. margin: 30rpx 0 30rpx 0;
  201. }
  202. .info {
  203. margin-top: 2%;
  204. border-radius: 40rpx;
  205. padding: 2% 4%;
  206. box-shadow: rgba(100, 100, 111, 0.2) 14rpx 14rpx 40rpx 14rpx;
  207. }
  208. .submit {
  209. color: white;
  210. font-weight: normal;
  211. width: 55%;
  212. border-radius: 20rpx;
  213. background-color: #02a7f0;
  214. margin: 120rpx auto;
  215. }
  216. }
  217. .popup-box {
  218. height: 100%;
  219. display: flex;
  220. flex-direction: column;
  221. justify-content: space-between;
  222. }
  223. .popup-title {
  224. text-align: center;
  225. font-weight: bold;
  226. height: 30px;
  227. border-bottom: 1px solid #d8d8d8;
  228. }
  229. .popup-content {
  230. font-size: 28rpx;
  231. padding: 10rpx 0 10rpx 0;
  232. }
  233. .popup-type {
  234. display: flex;
  235. height: 80rpx;
  236. align-items: center;
  237. margin-top: 60rpx;
  238. view {
  239. width: 30%;
  240. }
  241. input {
  242. border: 1px solid #d7d7d7;
  243. width: 60%;
  244. border-radius: 5rpx;
  245. padding-left: 10rpx;
  246. height: 56rpx;
  247. }
  248. }
  249. .popup-footer {
  250. display: flex;
  251. button{
  252. font-size: 26rpx;
  253. height: 60rpx;
  254. width: 150rpx;
  255. line-height: 60rpx;
  256. color: #FFFFFF;
  257. }
  258. }
  259. .popup-cancel {
  260. background-color: #AAAAAA;
  261. }
  262. .popup-submit {
  263. background-color: #249CD3;
  264. }
  265. </style>