PageSourceSearch

https://www.ry-elerelay.com/assets/js/unit/cart-complete.js

js ry-elerelay.com collected 2026-10-04 04:35:36 UTC 6,666 bytes, 165 lines download raw bytes

1class ScriptCartComplete extends Script {
2  constructor(params) {
3    super(params)
4    this.utilts = Utilts.ins()
5  }
6  /** 初始化,支持异步 */
7  async init() {
8    await new Load('/assets/plugins/vue.min.js')
9    this.initVue()
10  }
11  initVue() {
12    const _this = this
13    new Vue({
14      el: `#${_this.attrId} .unit-complete__app`,
15      data: {
16        utilts: _this.utilts,
17        order_product: [],
18        order_address: [],
19        order_info: {},
20        order_id: 0,
21        product_number: 0,
22        discount_price: 0,
23        coupon_price: 0,
24        order_status_name: window.app.utilts.$t('shipment successful'),
25        request_success: false,
26        errorStr: ''
27      },
28      created() {
29        this.init()
30        const cartIds = window.Cookies.get('cartPayIds')
31        if (cartIds) this.deleteCart(cartIds)
32      },
33      methods: {
34        /** 删除多个产品 */
35        deleteCart(id) {
36          window.Cookies.remove('cartPayIds')
37          return new Promise((resolve, reject) => {
38            this.utilts.request({
39              url: '/shopping-cart/delete',
40              method: 'POST',
41              params: {
42                site_id: window.app.info.site.site_id,
43                visitor_code: window.app.info.user.visitor_code,
44                id: id
45              }
46            })
47              .then(() => {
48                _this.utilts.getCartQuantity()
49                resolve(true)
50              })
51              .catch(err => reject(err))
52          })
53        },
54        async init() {
55          window.app.info.utilts.postVisitor()
56          this.initOrderId()
57          await this.initOrderDetail()
58          this.initOrderStatus(this.order_info.status)
59          this.errorStr = this.utilts.getParamsByUrl('err')
60          const orderPayment = this.order_info.order_payment || {}
61          const info = orderPayment.payment_info || {}
62          const type = this.order_info.payment_type || info.payment_type
63          const gtagInfo = {
64            payment_type: this.utilts.getPaymentName(type),
65            order_id: this.order_info.serial_number
66          }
67          if (!this.errorStr && this.order_info.status === 1 && info) {
68            this.errorStr = info.pay_fail_msg || ''
69          }
70          if (this.errorStr) {
71            this.errorStr = decodeURI(this.errorStr)
72            this.utilts.setGtag('payment_failed', gtagInfo)
73          } else {
74            this.utilts.setGtag('payment_completed', gtagInfo)
75          }
76        },
77        /** 获取订单id */
78        initOrderId() {
79          const id = _this.utilts.getQuery('id')
80          this.order_id = Number(id)
81        },
82        /**获取订单详情 */
83        initOrderDetail() {
84          return new Promise(resolve => {
85            const orderVisitorCode = window.app.info.getOrderVisitorCode(this.order_id) || window.app.info.getVisitorCode()
86            _this.utilts.request({
87              url: '/order/detail',
88              method: 'GET',
89              params: {
90                id: this.order_id,
91                site_id: window.app.info.site.site_id,
92                visitor_code: orderVisitorCode
93              }
94            }).then(res => {
95              let json = res.data
96              if (json.shipment_surcharge) json.shipment_surcharge = (json.shipment_surcharge / 100).toFixed(2)
97              json.product_price = (json.product_price / 100).toFixed(2)
98              json.shipping_price = (json.shipping_price / 100).toFixed(2)
99              json.total_amount = (json.total_amount / 100).toFixed(2)
100              json.product_number = (json.total_amount / 100).toFixed(2)
101              json.discount_price = (json.discount_price / 100).toFixed(2)
102              json.reduction_price = (json.reduction_price / 100).toFixed(2)
103              json.coupon_price = (json.coupon_price / 100).toFixed(2)
104              this.product_number = 0
105              this.$set(this, 'order_info', json)
106              if (json.order_product && json.order_product.length > 0) {
107                let products = json.order_product.map(item => {
108                  item.price = (item.price / 100).toFixed(2)
109                  this.product_number += item.quantity
110                  const attr = Object.keys(item.product_attr_value).map(key => {
111                    return { title: key, content: item.product_attr_value[key] }
112                  })
113                  item.product_attr_value = attr
114                  this.total_price += (item.quantity * item.price)
115                  return item
116                })
117                this.$set(this, 'order_product', products)
118              }
119              if (!window.app.info.user.username && json.status != 1) {
120                window.app.info.setOrderVisitorCode(this.order_id, window.app.info.getVisitorCode())
121                // 游客支付后重置访客代码
122                window.app.info.resetVisitorCode()
123              }
124              resolve()
125            })
126          })
127        },
128        /** 订单状态 */
129        initOrderStatus(status) {
130          this.order_status_name = {
131            1: window.app.utilts.$t('Awaiting Payment'),
132            4: window.app.utilts.$t('Awaiting Shipment'),
133            12: window.app.utilts.$t('shipment successful'),
134            21: window.app.utilts.$t('Completed'),
135            31: window.app.utilts.$t('Cancelled')
136          }[status] || window.app.utilts.$t('shipment successful')
137        },
138        /** 去下一步 */
139        nextStep(event) {
140          window.app.utilts.setBtnLoadingStatus(event.target, true)
141          let url = ''
142          // 未支付状态时跳去支付页
143          const payment = this.order_info.order_payment.payment_info
144          // paypai 支付和信用卡支付如果未成功重新支付跳转到购物车支付页面
145          const isCrider = payment.payment_type === 11
146            || payment.payment_type === 13
147            || payment.payment_type === 14
148            || payment.payment_type === 15
149            || payment.payment_type === 17
150            || payment.payment_type === 18
151            || payment.payment_type === 19
152          if (this.order_info.status === 1 && !isCrider) {
153            url = `/checkout.html?id=${this.order_id}`
154          } else if (this.order_info.status === 1 && isCrider) {
155            url = `/cart.html?id=${this.order_info.id}&ad=${this.order_info.member_address_id}`
156          } else {
157            url = '/user.html#order'
158          }
159          const href = globalThis.Server.getRinseHref(url, window.app.info.site)
160          window.location.href = globalThis.Server.getRinseHref(`${location.origin}${href}`, window.app.info.site)
161        }
162      }
163    })
164  }
165}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.