You can use contains
function of underscore js to check in array items. And after use Magento_Ui/js/modal/modal
to show popup based on condition.
var myItems = ['1', '2', '3', '5'];
_.each(items, function (item, key) {
if(_.contains(myItems, item.product_id)) {
// productId available in myItems array
}
}, this);
Here is the sample code with open modal:
define([
'uiComponent',
'jquery',
'underscore',
'Magento_Ui/js/modal/modal'
], function (Component, $, _, modal) {
'use strict';
...
...
getCartItems: function () {
var items = this.getCartParam('items') || [];
var myItems = ['1', '2', '3', '5'];
_.each(items, function (item, key) {
if(_.contains(myItems, item.product_id)) {
$('body').append('<div id="modal">This is Model Content</div>');
var options = {
type: 'popup',
responsive: true,
title: 'Main title',
buttons: [{
text: $.mage.__('Ok'),
class: '',
click: function () {
//After click code
}
}]
};
var popup = modal(options, $('#modal'));
$('#modal').modal('openModal');
}
}, this);
items = items.slice(parseInt(-this.maxItemsToDisplay, 10));
return items;
},
...
...
}